Question: Complete the code for the while loop that randomly rolls a 6 side die (numbers 1-6) on each iteration and stops only when the die
Complete the code for the while loop that randomly rolls a 6 side die (numbers 1-6) on each iteration and stops only when the die lands on a 6.
On each roll, the output is printed.
Here is just one possible random example of the output.
2
1
5
4
1
Rolled a 6, all done.
Hint: randomNumber = random(LIMIT)
START
// DECLARATIONS
num randomNumber = 0
[Blank 1]
while [Blank 2]
[Blank 3]
[Blank 4]
endwhile
[Blank 5]
STOP
The options given to fill in the blanks are:
randomNumber != SIDE_OF_DIE
randomNumber = random(SIDE_OF_DIE)
output randomNumber
num SIDE_OF_DIE = 6
output "Rolled a 6, all done."
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
