java - Is there any questions on here in relation to only taking "Mr", "Mrs", "Miss" etc at keyboard Input? -


this code. want accept correct male , female titles. how should fix work because @ moment not working correctly.

boolean valid = false; scanner keyboardin = new scanner(system.in);         system.out.println("enter account details: "); {     system.out.print("enter title: ");     title = keyboardin.nextline();     if (title.equals("mr") || title.equals("mrs") || title.equals("ms") || title.equals("miss")) {         system.out.println("title set. ");     }     name.settitle(title);     else {         system.out.println("error!, must enter correct title. ");     } } while (!valid); 

boolean valid = false; scanner keyboardin = new scanner(system.in); system.out.println("enter account details: "); string title; {     system.out.print("enter title: ");     title = keyboardin.nextline();     if (title.equals("mr") || title.equals("mrs") || title.equals("ms") || title.equals("miss")) {         system.out.println("title set. ");         name.settitle(title);         valid = true;     } else {         system.out.println("error!, must enter correct title. ");     } } while (!valid); 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -