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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started