Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Lab 4.1-Repetition Structures Pseudocode Critical Review A repetition structure

ID: 3586239 • Letter: L

Question

Lab 4.1-Repetition Structures Pseudocode Critical Review A repetition structure causes a statement or set of statements to execute repeatedly Repetition structures are used to perform the same task over and over Repetition structures are commonly called loops A condition-controlled loop uses a true/false condition to control the number of times that t repeats A count-controlled loop repeats a specific number of times. The loop keeps a count of the number of times that it iterates, and when the count reaches a specified amount the loop stops. A variable, known as a counter variable, is used to store the number of iterations that it has performed. The three actions that take place are initialization, tes, and increment. Initialization: Before the loop begins, the counter variable is initialized to a starting value Test: The loop tests the counter variable by comparing it to a maximum value Increment: To increment a variable means to increase its value. This is done by adding one to the loop control variable · Any loop can be used with a count-controlled loop A running total is a sum of numbers that accumulates with each iteration of a loop. The variable used to keep the running total is called an accumulator Help Video: lab4-1.wmv This lab requires you to write a complete program using a condition controlled loop, a counter controlled loop, and an accumulator. The program is as follows Write a program that will allow a grocery store to keep track of the total number of bottles collected for seven days The program should allow the user to enter the total number of bottles returned for seven days. The program will calculate the total number of bottles returned f r the week and the amount paid out (the total returned times .10

Explanation / Answer

Step 1:- Module main()

                                totalBottles=0 //Integer type

                                counter=1

                                todayBottles=0

                                totalPayout=0 //Double type

                                keepGoing="y" //String type/Character type

Step 3:-                while(keepGoing=="y")

Step 2:-                                    getBottles(totalBottles,todayBottles,counter)

                                                calcPayout(totalPayout,totalBottles)

                                                printInfo(totalBottles,totalPayout)

                                                Display "Do you want to run the program again?"

                                                (Enter y for yes)."

                                                Input: keepGoing

                                End While

                End Module

Step 4:- Module getBottles(totalBottles, todayBottles,counter)

                                for(int i=counter;i<=7;i++)

                                                Display "Enter number of bottles returned for the day:"+counter

                                                Input: todayBottles

                                                totalBottles= totalBottles+todayBottles

                                End For

                End Module

Step 5:- Module calcPayout(totalPayout, totalBottles)

                                totalPayout=0 //resets to 0 for multiple runs

                                totalPayout=totalBottles*0.10;

                End Module

Step 6:- Module printInfo(totalBottles,totalPayout)

                                Display totalBottles

                                Display totalPayout

                End Module