I am trying to make a application and for one part of the application I need to get a input from the user stating how many times there click their mouse in 1 second. I want the
Use do while
loop instead of while
loop. This lets you run the loop atleast once before it tests the condition, where you can test the input.
String input = null;
do {
//get the input from user
} while (isInputValid); //check input validity here
Example:
Scanner input= new Scanner(System.in);
do {
System.out.println("Please enter the advertising cost: ");
advertCost = input.nextDouble();
} while (advertCost >= 100000 || advertCost <= 900000);
I have added link on how to validate inputs
Hope this helps!