If the user has entered the wrong data as to ask him to enter again?

If the user has entered the wrong data as to ask him to enter again ?
June 14th 19 at 18:53
1 answer
June 14th 19 at 18:55
A console application? Cycle start and go out of it only if the data is correct. A do-while loop/while you need.

Something like this:

do {
 System.out.println("Enter data: ");
} while(!input());


Or this:

System.out.println("Enter data: ");
while(!input()) {
 System.out.println("Incorrect input. Try again: ");
}


private boolean input()
{
 // We read the data, check their validity and return true if the input is valid and false if invalid.
}
Yes console while ? - Heloise_Boyle commented on June 14th 19 at 18:58

Find more questions by tags Java