/***************************************************************************
 * Written by Ben Mathew
 * for Cornell University CS 100 Summer 2001
 *
 * This program shows how to design a simple test based menu that continues
 * to ask for input until the user chooses to exit. Notice the use of the
 * method String.equals() in determining the menu choice.
 ***************************************************************************/

public class StringMenu1
{
    public static void main (String [] args)
    {
	
        String input; // a string to store the input
        
        //infinite loop to get input
        while (true)
            {	
                //display menu choices	
                System.out.println("Type hi to print hello world.");
                System.out.println("Type bye to exit.");
		
                //get user's choice
                input = SavitchIn.readLine();
                
                //test if input is valid
                if (input.equals("hi"))
                    {
                        System.out.println("\nHello World\n");
                    }
                
                else if (input.equals("bye"))
                    {
                        System.out.println("\nGoodbye");
                        System.exit(42); //command to quit program
                    }
                
                //if the user does not input either choice, then
                //print an error message and continue the loop
                else
                    {
                        System.out.println("\nCan you read?\n");
                    }
                
            }
        
    }
    
}
