Posted by Jean on .
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" );