Last active
August 29, 2015 14:20
-
-
Save danleyb2/f124b5f6d1e4a5e291a0 to your computer and use it in GitHub Desktop.
ask a question that only accept a YES or NO answer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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