Problem 58

Shorter Double Dice

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.

HERE COME THE DICE!

Roll #1: 3
Roll #2: 5
The total is 8!

Roll #1: 6
Roll #2: 1
The total is 7!

Roll #1: 2
Roll #2: 5
The total is 7!

Roll #1: 1
Roll #2: 1
The total is 2!

Frequently-Asked Questions

What is a do-while loop? I don’t have a good explanation written up. You’ll have to ask the Internet. I’m sorry.


◄ 57: Flip Again? 59: Again with the Number-Guessing ►



Adapted from ProgrammingByDoing.com
©2013 Graham Mitchell

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.