+ 1
7th Oct 2019, 1:53 AM
Andy M
Andy M - avatar
3 Respostas
+ 1
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 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? 6 First roll = 5 Second roll = 1 Third roll = 3 Die total = 9 Average roll = 3.0 How many sides? 20 First roll = 14 Second roll = 20 Third roll = 9 Die total = 43 Average roll = 14.333 (the number of decimals displayed doesn’t matter)
7th Oct 2019, 1:54 AM
Andy M
Andy M - avatar
0
Because it is random?
7th Oct 2019, 4:22 AM
jtrh
jtrh - avatar
0
so even if I put the number of sides it should have different values than sample output listed
7th Oct 2019, 4:43 AM
Andy M
Andy M - avatar