Skip to content

Instantly share code, notes, and snippets.

@danleyb2
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danleyb2/f124b5f6d1e4a5e291a0 to your computer and use it in GitHub Desktop.
Save danleyb2/f124b5f6d1e4a5e291a0 to your computer and use it in GitHub Desktop.
ask a question that only accept a YES or NO answer
public static String askQuestion(String question){
Scanner ans=new Scanner(System.in);
String response;
do{
System.out.println(question);
response=ans.next();
}while(!response.equalsIgnoreCase("yes")||!response.equalsIgnoreCase("no"));
return response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment