1prompt the user for the number of sides on the die2roll


Problem 1: Dice Write a program that simulates rolling one die

Write a program that simulates rolling one die using the following steps:


1.Prompt the user for the number of sides on the die.
2."Roll" the die three times by generating a random number between 1 (inclusive) and the number of sides (inclusive).
3.Keep track of the running sum of the rolls for the die and output the sum and average for the three rolls at the end.
4.You can set up one integer variable named roll, and reuse it with each roll of the die. You will also need a variable named total, initialized to zero.

Sample Output:

How many sides on die? 6
First roll = 5
Second roll = 1
Third roll = 3
Die total = 9 
Average roll = 3 

How many sides on die? 20
First roll = 14
Second roll = 20
Third roll = 9
Die total = 43 
Average roll = 14.333

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: 1prompt the user for the number of sides on the die2roll
Reference No:- TGS01123124

Expected delivery within 24 Hours