Question: Practice while and for loops. Please read the instructions carefully and ask questions if you do not fully understand what to do. Name your class


Practice while and for loops. Please read the instructions carefully and ask questions if you do not fully understand what to do. Name your class LoopDemo1. Write three loops in your main method as follows: 1. Use a while loop to create a comma-separated list of names. Prompt the user for each individual name that gets added to the list. Stop adding to the list when the user enters "exit." Start with initial one-name list and add", [new namel" each additional iteration 2. Use a while loop to generate the factorials that are less than a given limit (10000). Test with different limits. 3. Use a for loop to generate the factorials up to and including n-factorial. Make sure it works for different values of n. You can use the same n that is set after the prior factorial loop and check that you get the same output. Here is sample output from a run of a completed program: ---- GRASP exec: java LoopDemo1 Enter a name or the word exit: Michael Enter another name or the word exit: Lynn Enter another name or the word exit: Helen Enter another name or the word exit: Paul Enter another name or the word exit: exit Name list: Michael, Lynn, Helen Paul Factorial while loop fn(O): 1 fn(1): 1 fn(2): 2 fn(3): 6 fn(4): 24 fn(5): 120 fn(6): 720 fn(7): 5040 Factorial for loop fn(o): 1 fn(1): 1 fn(2): 2 Factorial for loop fn(0): 1 fn(1): 1 fn(2): 2 fn(3): 6 fn(4): 24 fn(5): 120 fn(6): 720 fn(7): 5040 ----GRASP: operation complete
Step by Step Solution
There are 3 Steps involved in it
Here is a Java program that fulfills the requirements using loops as described java import javautilS... View full answer
Get step-by-step solutions from verified subject matter experts
