Post a New Question

Computer Programming

posted by .

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
56
789
4
8999
231


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:

56
43
2
99
767
1
"The product is: ___"
then the menu will be displayed again and the use prompted for a choice.

This is what I have so far...

import java.io.*;

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);

switch(input)
{
case 0:
break;
case 1:

break;
case 2:

break;
default:
System.out.println( "Invalid Selection" );
break;
}

System.out.println( "Bye Bye" );
}
}

Respond to this Question

First Name
School Subject
Your Answer

Similar Questions

  1. programming

    creat a logic for a program that continuously prompts the user for a numeric number of dollars until the user enters 0. pass each entered amount to a conversion method that displays breakdown of the passed amount into the fewest bills
  2. Programming in c++

    Write a program in c++ that inputs a number [1-12] from the user and displays the month. it also asks the user whether he wants to input another number or not, if the user inputs 1 then it again inputs number, if user inputs 0 then …
  3. programming

    Pseudocode - Create the logic for a program that continuously prompts a user for a numeric value until the user enters 0. The application passes the value in turn to a method that squares the number and to a method that cubes the number. …
  4. programming

    Create the logic for a program that continuously prompts a user for a numeric value until the user enters 0. The application passes the value in turn to a method that squares the number and to a method that cubes the number. The program …
  5. programming pseudocode

    Create the logic for a program that continuously prompts a user for a numeric value until the user enters 0. The application passes the value in turn to a method that squares the number and to a method that cubes the number. The program …
  6. computer programming

    Develop a menu-driven program that inputs two numbers and, at the user's option, finds their sum, difference, product, or quotient.
  7. programming

    Write a program which allows user to enter 10 student names and scores for Java programming 1 and Java programming 2. Allow user to choose which course they want to enter the record for. Use the loop to ask input from user. The program …
  8. java programming

    the learner is asked to write a program using java with user input that caculate and displays, the number of months it will take the user to save an amount of money. the user must enter the
  9. Computer Science/Pseudo Code Python

    Hi, I'm confused about an assignment. I'm not sure what to do and would like some help. An example: Write a program that obtains two integer numbers from the user. It will print out the sum of those numbers. Pseudo code: Prompt user …
  10. Ic

    Write an application that prompts the user for two integers and then prompts the user to enter an option as follows: 1 to add the two integers, 2 to subtract the second integer from the first, 3 to multiply the integers, and 4 to divide …

More Similar Questions

Post a New Question