Tuesday, July 14, 2009

Java program?

Write a Java program that asks a user to type A,B,C or Q. When the user types Q, the program ends. When the user types A,B or C, the program displays the message "Good Job!" and then asks for another input. When the user types anything else, issue an error message and then ask for another input. The class name is ABCInput.

Java program?
BufferedReader BR =new.................................


while(true){


System.out.print("Input A B,C or Q: ");


String Input= BR.readLine();


if(Input.equals("A") || Input.equals("B") || Input.equals("C"))


{


System.out.println("Good");


}


else if(Input.equals("Q")){ break;}


else{System.out.println("Issued an Error message");}





}
Reply:lol... that guy is quite frank... it's actually not that rude.. but u really should do it yourself. the input entry should be under switch statement. for the main, u can actually make use of do-while loop or even if else ;-) the more u try it urself, the better u'll get!!
Reply:Do your assignment yourself! Please ask specific questions, dont ask for the whole solution... Its really rude! Trust me!
Reply:This sounds like homework to me!





As a hint, use a switch statement for the letter input.
Reply:U can use a switch statement or and if statement to determine what the user has inputted. Use the scanner class. It is not that hard using the if statement. Also u need a while loop.


No comments:

Post a Comment