francis mag
Need help with console program?
1 Answer(s)      2 years and 9 months ago
Posted in : Java Beginners

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.

Advertisement
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();
        }
    }
}