Hello, I am new to this forum and need a little help.
I am taking an intro to Java Course and we are creating a project that reads in a set of user inputted numbers and stops when the user inputs any letter.
From a textbook example they have the code quit when Q is entered. However, I need the code to stop when any letter is entered.
If anyone could help me with this I would greatly appreciated it.
Thank you, code at bottom.
DataAnalyzer
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
DataSet data = new DataSet();
boolean done = false;
while (!done)
{
System.out.print("Enter value, Q to quit: ");
String input = in.next();
if (input.equalsIgnoreCase("Q"))
done = true;
else
{
double x = Double.parseDouble(input);
data.add(x);
}
}