Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Master The Art Of Data Storytelling With Visualizations

Authors: Alexander N Donovan

1st Edition

B0CNMD9QRD, 979-8867864248

More Books

Students also viewed these Databases questions