The program should give the output "Invalid Input
" when the user inputs a string (eg. "thirty
"), then prompt the user to type a valid input. When I type a string, I get the error message Exception in thread "main" java.util.InputMismatchException
when inputting a string.
public static void main(String[] args) {
double wallHeight = 0.0;
boolean valid = true;
// Implement a do-while loop to ensure input is valid
// Prompt user to input wall's height
do {
System.out.println("Enter wall height (feet): ");
wallHeight = scnr.nextDouble();
valid = true;
if (wallHeight <= 0) {
System.out.println("Invalid Input");
valid = false;
}
} while (!valid);