Dice Thrower

Dice image

Step 4 – choose the number of sides

Now lets allow the user to choose how many sides their die has.

To do this we need to use one of those input lines. Part of the line involves storing the value in a variable. I'm called my variable sides because it's storing the number of sides on the die.

The rest of this is quite easy.

  1. It would probably be fine to use the program you just had and change it
  2. Be careful with brackets here – especially on the input line
  3. Save your program
  4. Run the program to check that it works
  5. Make sure you run your program a few times. Choose different sides each time

You can enter any number. If you want a random number between 1 and 1024 then enter 1024 when prompted.

Code helper image

The die rolls should be random.