import java.io.*; 
  
public class YesNo 
{ 
  static String getAnswer() throws Exception 
  { 
    String result = ""; 
  
    BufferedReader cin; 
    cin = new BufferedReader(new InputStreamReader(System.in)); 
  
    while (true) 
    { 
      System.out.print("Your answer [yes/no]: "); 
      result = cin.readLine(); 
      if (result.equals("yes")) break; 
      if (result.equals("no")) break; 
      System.out.print("Let's try this again. "); 
    } // while 
  
    return result; 
  } // getAnswer 
  
  public static void main(String[] argv) throws Exception 
  { 
    // do stuff... 
    if (getAnswer().equals("yes")) 
    { 
      // do stuff... 
    } // if 
  } // main 
} // public class 
