Friday
July 31, 2015

Homework Help: Computer Programming

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

Answer this Question

First Name:
School Subject:
Answer:

Related Questions

More Related Questions

Members