What is condition-controlled loop? Condition- enthroned loop uses a true/ false condition to control the number of times that it repeats. What is a count-controlled loop? Count-controlled loop repeats specific number of times. What are three actions do count-controlled loop typically performed using the counter variable? Initialization, Test, Increment Algorithm Workbench Design a While loop that lets the user enter a number. The number should be multiplied by 10, and the result stored in a variable named product.
The loop should iterate as long as product contains a value less than 100.
//Declare product = O Do Display “Enter a number.
” Input number Product = number x 10 While product < = 100 Design a Do-while loop that asks the user to enter two numbers. The numbers should be added and the sum displayed. The loop should ask the user if he or she wishes to perform the operation again. If so, the loop should repeat, otherwise it should terminate.
Declare Minimum as Reliance ENUM as Reallocate sum as realistically “What is your first number”lineup 1 individuals ‘What is your second enfeeblement’s unassuming Minimum+individuals “sum mum” Convert the While loop in the following code to Do-While loops: Declare Integer x While x > O Display “Enter a number. Input x End While Declare x as Integer = 1 DO If x ! = O then Display ‘Try again” End if until x -o Display number you entered is correct” Convert the Do-While loops in the following code to a While loop: Declare String sure Display “Are you sure you want to quit? Input sure While sure ! = “Y” And sure Convert the following Do While loop to a Do Until loop: structuring = String. Empty Do While structuring. Toupee ” Y” Structuring = Inputted(” Are you sure you want to quit? ) Loop Programming Exercises Bug Collector A bug collector collects bugs every day for seven days. Design a program that peps a running total of the number of bugs collected during the seven days. The loop should ask for the number of bugs collected for each day, and when the loop is finished, the program should display the total number of bugs collected.
Declare counter as integer =1 Declare bugs as integer = O Declare totals as integer = 0 For counter Display ” Enter of bugs collected today. ” Input bugs Set totals = totals + bugs End for Display ‘The total number of bugs collected this week was: totals Budget Analysis Design a program that asks the user to enter the amount that he or she has budgeted for a month. A loop should then prompt the user to enter each of his or her expenses for each month, and keep a running total.
When the loop finishes, the program should display the amount that the user is over or under budget. Declare Talladega as integer = O Declare totalities as integer = 0 Declare budget as integer = O Declare bill as integer = 0 Display “Enter your monthly Budget ” Input budget Display “Enter the amount bayou bill” Input bill totalistic = bill + bill Set Talladega = budget – bill If Talladega < = 0 then Display ” You are over your budget. Your budget is “, budget, ” and you are at “, delegate Until bill = O Display mayo are under budget.
Cite this Condition-Controlled Loop Description
Condition-Controlled Loop Description. (2018, Jul 03). Retrieved from https://graduateway.com/condition-controlled-loop-description/