On average, how many times must a die be rolled until 6 comes up? Let's find out!
The plan here is to roll a die in variable roll. If the roll comes out to be ?? (you know what to fill in, right?), then we'll insert the number of rolls we needed (held in variable c), into an array called rolls. The array rolls will keep track of the numbers of rolls we needed until a 6 showed up.
Next, we'll find the average of the numbers in array rolls and display it to the screen.
Now you try. Fix N, then fix up the other ?? groups until the code works properly.
Type your code here:
See your results here:
Share your code
Show a friend, family member, or teacher what you've done!