This code keeps asking the user for double values till the user enters an empty line. When a user enters a non double value such as a string, an Invalid input message is displayed. Currently, even when the user enters an empty line, the invalid input message shows up, and I understand why. What would be the best way to get Invalid input to not show up when I enter a blank line. I'm not sure if there's a way using try-catch or if I just need to use something else.
System.out.println("Type in the polynomials in increasing powers.");
Scanner prompt = new Scanner(System.in);
String input = " ";
double parsed;
int counter = 0;
while (!(input.equals("")) & counter < 10) {
input = prompt.nextLine();
try {
parsed = Double.parseDouble(input);
expression.addCoefficient(parsed);
counter++;
}
catch (NumberFormatException e) {
System.out.println("Invalid input");
}