Prompt the user for the number of sides on the die

Assignment Help Basic Computer Science
Reference no: EM13842915

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

Reference no: EM13842915

Questions Cloud

Theurl of the article : Find 1 article related to  security and the cloud. and to turn in the following: (1) TheURL of the article, (2) A brief summary of the article
Principles of good design and usability attributes : All assignments must be prepared in double-space format, 12 pt. type (preferably TimesRoman), and should include a title page, table of contents, and reference list. Allsubmitted work should contain student name and course number and term
Standard deviation abstract : Standard Deviation Abstract
First describe the mission of each organization : First describe the mission of each organization, as found on their web site.  Discuss how each organization has been targeted in the recent past for cyberattack(s), as reported in news or journal articles.  Describe the suspected threat actors.  Disc..
Prompt the user for the number of sides on the die : 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 ..
What is the calculated t value : Conduct a hypothesis test and What is the calculated t value? Are the mean test scores of these two groups significantly different at the .05 level - Conduct a hypothesis test.
Write a grand strategy plan addressing : Write a grand strategy plan addressing
Explain how companies can use information technology : Explain how companies can use Information Technology to make their businesses more competitive. Provide at least 1 or 2 examples and explain how they help.
Review the segmentation data : review the segmentation data

Reviews

Write a Review

Basic Computer Science Questions & Answers

  What value is the log function sensitive

If x~y(both have values close to each other but not same), then we would expect some cancellation in computing log(x)-log(y). on the other hand, log(x)-log(y)=log(x/y), and the latter involves no cancellation. Does this mean that computing log..

  What is the paintcomponent method

What is the paintComponent method? How is it used in Java graphics? How does a program intentionally cause the paintComponent method to execute?

  The leading business organizations

Boardman Management Group is one of the leading business organizations of today's time. They are planning to make a resort, Baderman Island Resort. The overall organization is vastly spread in number of countries. It has numerous branches in al..

  Write program mips assembly calculate fibonacci series

I want to write program in MIPS Assembly Language to calculate first 100 terms in Fibonacci series.

  Cyber security in business organizations

Determine the fundamental challenges that organizations face in general in regard to protecting organizational assets and information.

  Takes non-negative integer

Then implement function drawLevy() so it takes non-negative integer n as input and draws the levy curve Ln using instructions obtained from function levy(). Don't forget doc strings and comments.

  Explaining resulting scheme is not ind-cpa-secure

Let a variant of CBC-mode encryption where sender simply increments the IV by 1 each time a message is encrypted. Illustrate that resulting scheme is not IND-CPA-secure.

  Write a declaration for an enumerated data type

A pet store sells dogs, cats, birds, and hamsters. Write a declaration for an enumerated data type that can represent the types of pets the store sells.

  Calculate and output the following statistics

A player wins by collecting all the cards. If a player runs out of cards while dealing the face-down cards of a war, he may play the last card in his deck as his face-up card and still have a chance to stay in the game. Once a single player holds ..

  Create queue class should have the following methods

create queue class should have the following methods:

  Tradeoffs involved to improve overall system performance

What are your thoughts on the tradeoffs involved when attempting to improve overall system performance. Provide examples where an increase in the performance of one resource.

  Apple versus samsung

Apple iPads continue to be successful. The Samsung Galaxy Tab is one (1) of iPad's competitors. Use the Internet and Strayer Library to research the advantages and disadvantages of these devices and to determine if they are comparable.

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