subject

1) Create 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) Create 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 number is entered, such as "do sum" or "do factorial", read it with the Scanner next(), then call the appropriate method in a switch.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 18:20
Write a javascript program that reads three integers named start, end, and divisor from three text fields. your program must output to a div all the integers between start and end, inclusive, that are evenly divisible by divisor. the output integers must be separated by spaces. for example, if a user entered 17, 30, and 5, your program would output "20 25 30" (without the quotes) because those are the only integers between 17 and 30 (including 17 and 30) that are evenly divisible by 5.
Answers: 2
question
Computers and Technology, 22.06.2019 10:30
You have a large, late-model pick-up truck with a rear seat. the pick-up truck weighs 6,500 pounds. the florida seat belt law
Answers: 1
question
Computers and Technology, 22.06.2019 15:30
To increase sales, robert sends out a newsletter to his customers each month, letting them know about new products and ways in which to use them. in order to protect his customers' privacy, he uses this field when addressing his e-mail. attach bcc forward to
Answers: 2
question
Computers and Technology, 22.06.2019 19:10
What a backup plan that you have created in a event you encounter a situation
Answers: 2
You know the right answer?
1) Create a method Sum to include a FOR loop. Get a scanner and input a number form the keyboard in...
Questions
question
History, 20.05.2021 03:00
question
Mathematics, 20.05.2021 03:00
question
Mathematics, 20.05.2021 03:00
question
Mathematics, 20.05.2021 03:00
question
Mathematics, 20.05.2021 03:00
question
English, 20.05.2021 03:00
question
Physics, 20.05.2021 03:00
Questions on the website: 13722367