Create a main method with a switch statement


Problem

I. Create a main() method with a switch statement that calls either a sum() OR factorial() method, depending on what selection the user of the program makes - ask the user to enter a selection (with System.out.println()), create a Scanner then read the user's input with a call to Scanner next(), then call the appropriate method in a switch (the String that was read from the call to Scanner.next() should be what you use as your switch condition).

II. Create a method, sum(), to include a FOR loop that will:

Get a scanner and input a number from the keyboard in main(). The method will take one parameter and calculate the sum up to that number. For example, if you pass 5, it it will calculate 1+2+3+4+5 and will return it back to main() method.

III. Create another method, factorial(), and repeat what was done for the sum() method above but compute the product instead.

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Create a main method with a switch statement
Reference No:- TGS03242093

Expected delivery within 24 Hours