In games with two dice (such as Monopoly), rolling two 6-sided dice and getting the same...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
In games with two dice (such as Monopoly), rolling two 6-sided dice and getting the same side or number on both dice is called "doubles" (i.e. the first die rolls a 5 and the second die rolls a 5 at the same time). One special type of "doubles" roll is called "snake eyes," which is rolling two 1's at the same time. For this assignment you will be writing a program which first prompts the user for the number of sides to the dice they will be rolling. Your user should be able to input any positive value greater than or equal to 3 for the # of the sides on their dice, and you can assume that they will enter integers (not floats or strings). You will need to validate their input before you continue (i.e. entering -10 should cause your program to tell the user that their input is invalid). You should re-prompt the user to enter a value if they supply bad data. Hint: use a "while" loop to keep the user "trapped" until they supply you with "good" data. 8 N 2 20 12 2 Some multi-sided dice Next, your program should keep "rolling the dice" until it gets snake eyes. This means that you will roll two virtual dice of the specified size at a time. The program should "announce" every pair rolled and then tell the user how many "rolls" were required to get a pair of ones. You should also keep track of how many times your roll came up with "doubles" along the way (but you shouldn't end the program until you roll "snake eyes") In addition, you will want to calculate the average roll for each die and present this information to the user. See the sample program below to see what this should look like. You should format this number to two decimal places. # Sample input: How many sides on your dice? -10 Sorry, that's not a valid size value. Please enter a size of at least 3. How many sides on your dice? 6 Thanks! Here we go... # Sample output: 1. die number 1 is 5 and die number 2 is 3. 2. die number 1 is 2 and die number 2 is 2. 3. die number 1 is 1 and die number 2 is 5. 4. die number 1 is 5 and die number 2 is 1. # The loop continues until... 16. die number 1 is 1 and die number 2 is 1. You got snake eyes! Finally! On try number 16! Along the way you rolled doubles 5 times The average roll for die #1 was 2.95 The average roll for die #2 was 3.20 In games with two dice (such as Monopoly), rolling two 6-sided dice and getting the same side or number on both dice is called "doubles" (i.e. the first die rolls a 5 and the second die rolls a 5 at the same time). One special type of "doubles" roll is called "snake eyes," which is rolling two 1's at the same time. For this assignment you will be writing a program which first prompts the user for the number of sides to the dice they will be rolling. Your user should be able to input any positive value greater than or equal to 3 for the # of the sides on their dice, and you can assume that they will enter integers (not floats or strings). You will need to validate their input before you continue (i.e. entering -10 should cause your program to tell the user that their input is invalid). You should re-prompt the user to enter a value if they supply bad data. Hint: use a "while" loop to keep the user "trapped" until they supply you with "good" data. 8 N 2 20 12 2 Some multi-sided dice Next, your program should keep "rolling the dice" until it gets snake eyes. This means that you will roll two virtual dice of the specified size at a time. The program should "announce" every pair rolled and then tell the user how many "rolls" were required to get a pair of ones. You should also keep track of how many times your roll came up with "doubles" along the way (but you shouldn't end the program until you roll "snake eyes") In addition, you will want to calculate the average roll for each die and present this information to the user. See the sample program below to see what this should look like. You should format this number to two decimal places. # Sample input: How many sides on your dice? -10 Sorry, that's not a valid size value. Please enter a size of at least 3. How many sides on your dice? 6 Thanks! Here we go... # Sample output: 1. die number 1 is 5 and die number 2 is 3. 2. die number 1 is 2 and die number 2 is 2. 3. die number 1 is 1 and die number 2 is 5. 4. die number 1 is 5 and die number 2 is 1. # The loop continues until... 16. die number 1 is 1 and die number 2 is 1. You got snake eyes! Finally! On try number 16! Along the way you rolled doubles 5 times The average roll for die #1 was 2.95 The average roll for die #2 was 3.20
Expert Answer:
Related Book For
Java How To Program Late Objects Version
ISBN: 9780136123712
8th Edition
Authors: Paul Deitel, Deitel & Associates
Posted Date:
Students also viewed these programming questions
-
C++ Very Important to Read: For program 2 you will be using a string class to read from a file, sort and then output some string . I will give you most of the code for the string class called...
-
Oriole Ltd. had the following transactions in its first month of operations: 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. Issued 18,000 common shares in exchange for $90,000 cash. Took out a $24,900 loan from the...
-
Why might cloud computing be greener than conventional computing alternatives? Research online and share examples suggesting that cloud firms could be less environmentally taxing than if a firm built...
-
Convert to scientific notation: 4,509,000.
-
A mouse is chased by a cat running in a straight line toward a hole in the wall at a speed of 4 . 0 m / s . The wall is at 6 m from the mouse. The cat is 4 m behind the mouse and running at 6 . 0 m /...
-
Describe a patients rights during labor disputes.
-
We would like to execute the loop below as efficiently as possible. We have two different machines, a MIMD machine and a SIMD machine. for (i=0; i < 2000; i++) for (j=0; j <3000; j++) X_array[i][j] =...
-
Suppose the exchange rate between U.S. dollars and Swiss francs is CHF 0.92 = $1.00, and the exchange rate between the U.S. dollar and the euro is $1.00 = 0.84 euro. What is the cross rate of Swiss...
-
Initially, inside a rigid cylinder, there is a certain amount of mass M of superheated water vapor at T1=250deg C and p1=1MPa with its initial specific internal energy u1.The circular lids of the...
-
1. What are the three primary ways minerals can form/grow? Give a description of each processes. 2. List, briefly describe the five characteristics (not properties) of a mineral. 3. What is the...
-
A researcher estimates an earning function by OLS using a country's Labor Force Survey data for one year. The dataset contains information on 2,000 individuals. The researcher obtained the following...
-
A Thermopane window of area 10 m2 is constructed of two layers of glass, each 10 mm thick, separated by an air space of 5 mm. If the inside is at 20 oC and the outside is at -30 oC. The thermal...
-
Nena ( an 8 0 ' s pop band from Germany ) sang a song about 9 9 balloons ( they were "luftballoons" in German, but in English, they were "red balloons" ) . If the sound level of a single balloon...
-
The primary coil of a transformer has 290 turns and its secondary coil has 580 turns. Round all answers to two decimal places, as needed. If the ac voltage applied to the primary coil is 150 V, what...
-
What is deadlock? Preventing and avoiding of deadlocks? Let the deadlock happen so prevent it and recover it?
-
You are a U.S. investor who purchased British securities for 2,000 one year ago when the British pound cost U.S. $1.50. What is your total return (based on U.S. dollars) if the value of the...
-
A \(0.010-\mathrm{kg}\) bullet is fired from a \(5.0-\mathrm{kg}\) gun with a muzzle velocity of \(250 \mathrm{~m} / \mathrm{s}\). (a) While the bullet is traveling in the barrel, what is the ratio...
-
A \(1500-\mathrm{kg}\) car going at \(6.32 \mathrm{~m} / \mathrm{s}\) collides with a \(3000-\mathrm{kg}\) truck at rest. If the collision is totally inelastic and takes place over an interval of...
-
On a low-friction track, a \(0.66-\mathrm{kg}\) cart initially going at \(1.85 \mathrm{~m} / \mathrm{s}\) to the right collides with a cart of unknown inertia initially going at \(2.17 \mathrm{~m} /...
Study smarter with the SolutionInn App