56. Do-While Swimming - Link
- Task
- Answer
- Question
So far you have only worked with one type of loop: the
while loop. But there is another type: the “do-while” loop.The do-while loop works almost exactly like a while loop. In fact, most of the time they are equivalent. Examine the program below to see if you can figure out the tiny difference.Files NeededSample OutputGoofus and Gallant are both going swimming. They hate to swim in cold water; once the water temperature drops below 79°F, they stop.Run the program, and type in 80.5 for the water temperature.57. Flip Again? - Link
- Task
- Answer
- Question
In this program, you’ll see how using a do-while loop might be better than a
while loop.Files NeededSample OutputThe code I have provided does not compile. Once you fix it, it will look roughly like this.58. Shorter Double Dice - Link
- Task
- Answer
- Question
Redo the Dice Doubles assignment (the dice program with a loop) so that it uses a
do-while loop instead of a while loop. Otherwise it should behave exactly the same.If you do this correctly, there should be less code in this version.Sample Output59. Again with the Number-Guessing - Link
- Task
- Answer
Redo the Number-Guessing with a Counter assignment using a
do-while loop instead of a while loop. Otherwise it should do exactly the same things (including the counter).Make sure that it doesn’t mess up if you guess it on the first try.Sample Output114. Baby Calculator - Link
- Task
- Answer
Write a calculator program that allows the user to add, subtract, multiply or divide two numbers. (This is sometimes called a “four-function” calculator.)The program must loop until they enter a zero as the first number.Files NeededSample Output