Exercise 4 DiceRoll Game In the Dice Roll game, the player begins with a score of...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Exercise 4 DiceRoll Game In the Dice Roll game, the player begins with a score of 1000. The player is prompted for the number of points to risk and a second prompt asks the player to choose either high or low. The player rolls two dice and the outcome is compared to the player's choice of high or low. If the dice total is between 2 and 6 inclusive, then it is considered "low". A total between 8 and 12 inclusive is "high". A total of 7 is neither high nor low, and the player loses the points at risk. If the player had called correctly, the points at risk are doubled and added to the total points. For a wrong call, the player loses the points at risk. Create a DiceRollGame application that uses a DRPlayer object based on this specification. The DRPlayer object should have two Die member variables that represent the dice. The Die class should use a random number generator to determine the outcome in a roll() method. Application output should look similar to: You have 1000 points. How many points do you want to risk? (-1 to quit) 10 Make a call (0 for low, 1 for high): 1 You rolled: 10 You now have 1020 points. How many points do you want to risk? (-1 to quit) 20 Make a call (0 for low, 1 for high): 1 You rolled: 11 You now have 1060 points. How many points do you want to risk? (-1 to quit) 20 Make a call (0 for low, 1 for high): 1 You rolled: 7 You now have 1040 points. How many points do you want to risk? (-1 to quit) -1 Exercise 4 DiceRoll Game In the Dice Roll game, the player begins with a score of 1000. The player is prompted for the number of points to risk and a second prompt asks the player to choose either high or low. The player rolls two dice and the outcome is compared to the player's choice of high or low. If the dice total is between 2 and 6 inclusive, then it is considered "low". A total between 8 and 12 inclusive is "high". A total of 7 is neither high nor low, and the player loses the points at risk. If the player had called correctly, the points at risk are doubled and added to the total points. For a wrong call, the player loses the points at risk. Create a DiceRollGame application that uses a DRPlayer object based on this specification. The DRPlayer object should have two Die member variables that represent the dice. The Die class should use a random number generator to determine the outcome in a roll() method. Application output should look similar to: You have 1000 points. How many points do you want to risk? (-1 to quit) 10 Make a call (0 for low, 1 for high): 1 You rolled: 10 You now have 1020 points. How many points do you want to risk? (-1 to quit) 20 Make a call (0 for low, 1 for high): 1 You rolled: 11 You now have 1060 points. How many points do you want to risk? (-1 to quit) 20 Make a call (0 for low, 1 for high): 1 You rolled: 7 You now have 1040 points. How many points do you want to risk? (-1 to quit) -1
Expert Answer:
Answer rating: 100% (QA)
Prompt the user for the number of points to risk risk intinputHow many points do you want to risk 1 ... View the full 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
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
Albert owns 100% of the shares of ProTech Services Inc and is has decided to sell the business. He initially invested STG 100,000 in the shares of the business 20 years ago. He has negotiated a...
-
The following table lists the prices of a small market basket purchased in both 2005 and 2015. Assuming that this basket of goods is representative of all goods and services, (a) Compute the cost of...
-
Insert the correct sign of inequality (> or
-
The production department of Zunni's Manufacturing is considering two numerically controlled drill presses; one must be selected. Comparison data is shown in the table below. MARR is 10 percent/year....
-
Foyle Architects incorporated as licensed architects on April 1, 2014. During the first month of the operation of the business, these events and transactions occurred: Apr.1.Stockholders invested...
-
A car traveling 87.0 km/h is 1500 m behind a truck traveling at 74.0 km/h. How far from its initial position does the car have to travel to catch up to the truck.
-
In the book Foundations of Financial Management ( 7th ed.), Stanley B. Block and Geoffrey A. Hirt discuss risk measurement for investments. Block and Hirt present an investment with the possible...
-
What is the transmission rate of information bits if you use ASCII (8 bits plus 1 parity bit), a 1,000-character frame, 56 Kbps modem transmission speed, 20 control characters per frame, an error...
-
Describe Design Thinking and apply the scenario of the Mobile Application System in describing each step. Include THREE (3) examples of Information Gathering technique to acquire more information...
-
Find the volume formed by rotating about the y-axis the region enclosed by: x = 10y and y = x with y 0
-
The energy equation for this problem must take into account several approximations. We will neglect viscous dissipation since the rod is solid. The only velocity is in the z-direction and that...
-
+2 If (x) = x+, find '(x) =
-
Consider a fin incorporating facilitated transport only at its base. The reaction occurring there is given by r=-kc (moles/s). The fin is essentially infinitely long, has a diameter, ro, and species...
-
dy Solve the first order linear differential equation + % , (0) 3 6. dx
-
The slopes of the tangents at the points where the curve y = x2 - 4x intersects the X-axis is 1) 1 2) +2 3) +3 4) +4
-
The recursive Towers of Hanoi. Write a animated solution to the Towers of Hanoi that shows the disks moving between pegs. Allow the user to enter the number of disks.
-
To round numbers to specific decimal places, use a statement like double y = Math.floor(x * 10 + 0.5) / 10; which rounds x to the tenths position (i.e., the first position to the right of the decimal...
-
Repeat Exercise 25.38 using the values 7 and 9. Exercise 25.38 Test each of the two equality and four relational operators on the two values 7 and 7. For example, 7 == 7, 7 < 7, etc.
-
Last year, Miley decided to terminate the S corporation election of her solely owned corporation on October 17, 2018 (effective immediately), in preparation for taking it public. At the time of the...
-
You have been assigned to compute the income tax provision for Motown Memories Inc. (MM) as of December 31, 2019. The companys income statement for 2019 is provided below: MM prepared the following...
-
Jane has been operating Mansfield Park as a C corporation and decides she would like to make an S election. What is the earliest the election will become effective under each of these alternative...
Study smarter with the SolutionInn App