Question: Using Java Programming 1.make a method Sum to include a FOR loop. Get a scanner and input a number form the keyboard in main(). The
Using Java Programming
1.make a method Sum to include a FOR loop.
Get a scanner and input a number form 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. Main method should call the method, get the sum back, and print a sum. You call the method from main() and get the result back to main()
2.make another method: Factorial that calculates a Product of same numbers, that Sum does for summing them up. Make sure you use FOR loop in it.
3.make a switch that Calls either sum(...) method OR factorial(...) method, depending on what user of the program wants. Ask the user to enter a selection, after the choice is entered, such as "sum" or "factorial", read it with the Scanner next(), then call the appropriate method in a switch.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
