Im on to validate all the inputs. When I run the program it only accepts if there is a "ms" or "Ms" or "Mr" or "mr" what is good. but when I enter "Mr" he sets the last word which I wrote wrong and set it as -title-. Then he skips the First Name input because he set already the right written "Mr" on it. The program works without validation. Why does it not accept the first "Mr" as title?
System.out.println("\nTitle of the student (eg, Mr, Ms): ");
while (!keyboard.hasNext("Mr") && !keyboard.hasNext("Ms") && !keyboard.hasNext("mr") && !keyboard.hasNext("ms")) {
{
System.out.println("Attention! Title must be Mr or Ms please choose one.");
list[i].setTitle(keyboard.next());
}
}
System.out.println("First name (given name)");
list[i].setFirstName(keyboard.next());
System.out.println("A last name (family name/surname)");
list[i].setFamilyName(keyboard.next());