Need help with console program?

Write a console program that repeatedly prompts the user to enter data until they type done (any case, Upper, Lower, or Mixed).

thanks in advance.

View Answers

July 12, 2012 at 10:44 AM

Here is an example that repeatedly prompts the user to enter data until they type 'done' in any case.

import java.io.*;

class Input 
{
    public static void main(String[] args) throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        System.out.print("Enter: ");
        String str=br.readLine();
        while(!str.equalsIgnoreCase("done")){
            System.out.print("Enter: ");
            str=br.readLine();
        }
    }
}









Related Tutorials/Questions & Answers:
Advertisements