Answered step by step
Verified Expert Solution
Question
1 Approved Answer
guidelines above please help must be written in Java!!! will upvote!! Directions: complete all the steps listed items as specified. Create a while, do-while, for
guidelines above please help must be written in Java!!! will upvote!!
Directions: complete all the steps listed items as specified. Create a while, do-while, for loop to process the number of hotdogs required by a user. Modify a loop construct where specified. When all is completed and error free, have your instructor check your work for credit. Loops 1. Declare and initialize a variable such as "dogPrice" or a variable name you prefer to $5.95. 2. The user initially wants 4 hotdogs. Create a ... loop ... that exits if the number of hotdogs drops below 1. Add a changer to the loop body that decrements by one. Add a loop counter so you know how many times the loop repeats. Display the number of times your loop looped! Instruction Initials Adding user input to the loop 1. Write a different kind of loop than in the previous steps that increments for every loop. 2. Prompt the user to enter the number of hotdogs they wish to purchase. Be descriptive in your user prompt, i.e., How many hotdogs to purchase or enter zero to exit? 3. Calculate the current price of the hotdogs ( 5.95 per dog) for the quantity ordered. Then add a re-prompt the user to see if they want to order more hotdogs. Now, setup the condition to exit if zero is entered by the user. Keep a running total from all loops to know the total purchase price of all dogs ordered. Once the loop exits, print the number of loops, total, and average cost of the hotdogs. Test, trace, all different scenarios and validate the loop condition exits correctly. 8. Label the initializer, changer, condition in comments Have your instructor check your work for credit. Instruction Initials Challenge: +5 Use any loop construct of your choice to: - generate the number of hotdogs up to 10 hotdogs possible using Math random() number generator. - each time the loop body executes, print the number of hotdogs purchased, the loop number, the current price of the hotdogs purchased to the Console. Instruction InitialsStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started