Program to simulate rolling one die

Assignment Help Programming Languages
Reference no: EM1347351

Q1) Write a program which simulates rolling one die using the following steps:

1. Prompt the user for 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

Reference no: EM1347351

Questions Cloud

Brand name products do you think have failed : What famous brand name products do you think have - What famous "brand name" products do you think have failed? Why do you think this happened? What might have been done to correct the problem?
Cvp analysis-academic approach : Avitar Corporation manufactures the line of computer memory expansion boards employed in microcomputers. The average selling price of its finished product is $175 per unit. The variable cost for these same units is $115. Avitar incurs fixed costs ..
Calculate the downward force of the water : An ideal spring has the spring constant k = 428 N/m. find the distance this spring must be stretched from its equilibrium position for 28 J of work to be done.
The theoretical m and m propositions : The differences between the theoretical M&M propositions and the practical applications for managers and where do managers say value is created?
Program to simulate rolling one die : Write a program which simulates rolling one die using the following steps: Prompt the user for the number of sides on the die.
Elucidate how much money supply will increase in response : Elucidate how much the money supply will increase in response to a new cash deposit of $500 by completing the accompanying table.
Modigliani and miller model-explantion : Modigliani and Miller model-Explantion by Example in Excel - Describe the Modigliani and Miller models of capital structure both with and without corporate income taxes.
What will be the initial speed of an arrow : A 100 g granite cube slides down a 40* frictionless ramp. At the bottom, just as it exits onto a horizontal table, it collides with a 200g steel cube at rest. How high above the table must the granite cube be released to give the steel cube a spee..
Find the effect on insurance contract : Determine what will an insurer do if it seems that an applicant misstated his or her age on life insurance application?

Reviews

Write a Review

Programming Languages Questions & Answers

  Subdividing address block among four different customers

The ISP needs to subdivide the address block among four different customers, requiring 29, 28, 27, and 26 hosts respectively.

  C program to accept three numbers inputs by user

Write down C program to accept three numbers input by a user, and outputs a table of temperatures in Fahrenheit, Celsius, and Kelvin.

  Reducing the average memory access time

Suppose that increasing the line size to 128 bytes increases the H to 0.97. Does this reduce the average memory access time?

  Ruby program that continuously reads in number

Write down Ruby program that continuously reads in number, x, from screen, and then calculates and displays its: factorial, if x is less than 15.

  Compute the product xy

Given two integers X and Y compute the product XY (multiplication), the quotient X=Y (integer division), and the modulus X (mod Y) (remainder).

  Explain about lexical analyzer

Explain about Lexical Analyzer

  Creating form which analyzes poker hand entered by user

To observe behavior of Sub Procedures, draw a Form which analyzes a poker hand entered by user and displays the type of hand.

  Writing program of long term parking

Write an enitre program about the long term parking, and calculate the parking total fare.

  Describe purpose of keyword super in programs

Describe purpose of keyword 'super' in programs

  Procedure to draw shape of choice

Write a program with a suitable procedure to draw shape of your choice. Your program must then call the procedure 10 times to draw the shape.

  Solve the programming problem

Solve the programming problem

  Technical project: sample website project

Technical Project: Sample Website Project , This assignment consists of three (3) sections: a narrative, a storyboard, and a business Website. You must submit all three (3) sections for the completion of this assignment.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd