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

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

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