Posted by Jean on Thursday, March 27, 2008 at 10:43am.
Java Programming Question:
basically want to keep the user in a loop that displays the menu and requests a user choice again and again until the user enters choice option 0 and exits the program.
When Option 1 is chosen, I want to ask the user, "How many numbers to add?" After they put in that number, I want to ask them, "Please enter the numbers one by one." like this
Then, the program will display the result by saying, "The sum is:...."
Finally the menu should be displayed again to choose from.
If Option 2 is selected:
- the user will NOT be asked how many numbers are to be multiplied. Instead, the program will accept numbers until the user enters the numer "1" which will signal the end of the number series. So the dialogue should look like this:
Please enter the numbers:
"The product is: ___"
then the menu will be displayed again and the use prompted for a choice.
This is what I have so far...
public class p2
private static BufferedReader stdin =
new BufferedReader( new InputStreamReader( System.in ) );
public static void main ( String  args ) throws IOException
System.out.println( "0-Exit" );
System.out.println( "1-Compute the sum of some numbers" );
System.out.println( "2-Compute the product of some numbers" );
String inputString = stdin.readLine();
int input = Integer.parseInt(inputString);
System.out.println( "Invalid Selection" );
System.out.println( "Bye Bye" );
Answer this Question
programming - Write a program which allows user to enter 10 student names and ...
Programming in c++ - Write a program in c++ that inputs a number [1-12] from the...
programming - creat a logic for a program that continuously prompts the user for...
programming - Create the logic for a program that continuously prompts a user ...
programming pseudocode - Create the logic for a program that continuously ...
programming - Pseudocode - Create the logic for a program that continuously ...
Computer programming - Sorting is a common operation used in programming. ...
programming - Using Raptor, create a condition loop that will ask the user for ...
programming - Create the logic for a program that continuously prompts the user ...
Programming Logic and Design: Comprehensive, 6th E - Create the logic for a ...