Create an application that rolls a pair of six-sided dice. Console Dice Roller ...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Create an application that rolls a pair of six-sided dice. Console ● ● Dice Roller ● Roll the dice? (y/n): y Die 1: 3 Die 2: 1 Total: 4 Roll again? (y/n): y Die 1: 1 Die 2: 1 Total: 2 Snake eyes! Roll again? (y/n): y Specifications You can use the random method of the Math class to generate a random number for a die like this: (int) (Math.random() * 6) + 1; Die 1: 6 Die 2: 6 Total: 12 Boxcars! Roll again? (y/n): n The application should display special messages for two ones (snake eyes) and two sixes (box cars). The application should use static methods to organize its code. The application should continue only if the user enters "y" or "Y" at the "Roll again?" prompt. Static methods private static String getUserChoice(Scanner sc, String prompt) { } private static int rollDie() { } private static void printDice(int die 1, int die2) { } private static void printSpecialMessage(int total) { } Create an application that rolls a pair of six-sided dice. Console ● ● Dice Roller ● Roll the dice? (y/n): y Die 1: 3 Die 2: 1 Total: 4 Roll again? (y/n): y Die 1: 1 Die 2: 1 Total: 2 Snake eyes! Roll again? (y/n): y Specifications You can use the random method of the Math class to generate a random number for a die like this: (int) (Math.random() * 6) + 1; Die 1: 6 Die 2: 6 Total: 12 Boxcars! Roll again? (y/n): n The application should display special messages for two ones (snake eyes) and two sixes (box cars). The application should use static methods to organize its code. The application should continue only if the user enters "y" or "Y" at the "Roll again?" prompt. Static methods private static String getUserChoice(Scanner sc, String prompt) { } private static int rollDie() { } private static void printDice(int die 1, int die2) { } private static void printSpecialMessage(int total) { }
Expert Answer:
Related Book For
Introduction to Probability
ISBN: 978-0716771098
1st edition
Authors: Mark Daniel Ward, Ellen Gundlach
Posted Date:
Students also viewed these programming questions
-
Create an application that stores data about your DVD collection in a file. The application should have a structure to hold the following fields: Video Name, Year Produced, Running Time, and Rating....
-
Create an application that accepts employee data interactively. Users might make any of the following errors as they enter data: The employee number is not numeric, less than 1000, or more than 9999....
-
A child rolls a pair of dice, one of which is blue and one of which is red. a. Given that the sum of the dice is 8, find the probability that the red die shows the value 4. b. Now the child rolls a...
-
Write statements that can be used in a JavaFX application to draw the five interlocking rings that are the symbol of the Olympics. (Dont worry about the color.)
-
Define objectives, strategies, and tactics, and explain how they differ.
-
Patients take a drug for severe acne for 6 months and there are 150,000 new patients each month. How many patients are taking this drug on average at any given time?
-
A stock price is governed by \[\frac{\mathrm{d} S}{S}=\mu \mathrm{d} t+\sigma \mathrm{d} z\] where \(z\) is a standardized Wiener process. Interest is constant at rate \(r\). An investor wishes to...
-
In 2011, Alliant Corporation acquired Centerpoint Inc. for $300 million, of which $50 million was allocated to goodwill . At the end of 2013, management has provided the following information for a...
-
Blue Mountain Hardware is adding a new product line that will require an investment of $1,510,000. Managers estimate that this investment will have a 10-year life and generate net cash inflows of...
-
Hannah Turnbull manages Elegant Suites, a hotel in a small town 10 miles inland from Florida's beautiful gulf coast. Elegant Suites has a capacity of 320 suites and offers a small, but well managed,...
-
-2 A 20 24) Fmd A (the mverse) and Sove these: HX=b4, Ax-b2,Ax-bs, and Ax:b4
-
Answer the following questions about IRAs: a. What is the maximum amount that may be contributed annually to the separate IRA of a nonworking spouse? b. Is it possible to contribute the maximum...
-
Harrison Bernhardt participates in his employers 401(k) plan. Under the plan, employees may elect to reduce their salary by a certain percentage and have it paid into the plans trust. In the current...
-
Abraham is single, age 48, has no employer- sponsored plan, and has a MAGI of $126,000 for 2019. What is the maximum contribution that he may make to a Roth IRA?
-
What formula is used in your state for apportionment of multistate income and what are your corporate income tax rates?
-
Bob owns 100 shares of Dylan Company. Dylan Companys other 400 outstanding shares are owned by unrelated parties. Bob bought the shares on December 14, 2009 for $20,000 ($200 per share). On August...
-
A company purchased assets costing $200,000 which will be depreciated over 5 years using straight-line depreciation and no salvage value. The company also purchased land and other assets, which are...
-
Provide a few individual examples who revealed what aspects of emotional intelligence?
-
Chris has an 18-pack of Gatorade sports drink: 6 orange, 6 lemon-lime, and 6 fruit punch. He blindly grabs one out of the pack over and over if necessary-without replacement-until he finds an orange...
-
As in Example 12.16, Jim and his brother both like chocolate chip cookies best. They have a jar of cookies with 5 chocolate chip cookies, 3 oatmeal cookies, and 4 peanut butter cookies. They are each...
-
Suppose that X, Y have constant joint density on the triangle with corners at (4, 0), (0, 4), and the origin. a. Find P(X < 3, Y < 3). b. Are X and Y independent?
-
Define internal combustion engine and explain how it is different from external combustion engines?
-
In an air standard Otto cycle, the pressure and temperature at the start of compression stroke are 1 bar and \(30^{\circ} \mathrm{C}\), respectively. The temperature at the end of compression is...
-
In I.C. engines, power developed inside the cylinder is known as: (a) Brake horse power (b) Indicated horse power (c) Pumping power (d) None of the above
Study smarter with the SolutionInn App