danleyb2
4/30/2015 - 2:38 PM

ask a question that only accept a YES or NO answer

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;
		
	}