(a) Create a Java class named RiskyDice (b) For this lab, I am providing you with...
Fantastic news! We've Found the answer you've been seeking!
Question:
![image text in transcribed](https://s3.amazonaws.com/si.experts.images/answers/2024/01/65b86670e8412_66465b86670bf264.jpg)
![image text in transcribed](https://s3.amazonaws.com/si.experts.images/answers/2024/01/65b866717405c_66565b8667147458.jpg)
Transcribed Image Text:
(a) Create a Java class named RiskyDice (b) For this lab, I am providing you with the main method, as shown here: public static void main(String[] args) { int pg = determine Play() ; if (pg != -1) { playGame (pg); } } (c) Above the main method, create a Random object. Make it a public static object, so that we can use it in any of our methods. (d) For this lab, we are making a dice game. You must first prompt the user for whether or not they wish to play the game. If the user does not want to play, exit. Otherwise, your program must simulate rolling a pair of dice between 3 to 5 times, as specified by the user. If the user specifies a number of rolls below 3, or above 5, you must re-prompt the user until they provide an appropriate number of rolls. After the rolls are complete, a single match means the user wins, otherwise the computer wins. (e) Your program needs the following methods that perform the following actions: determinePlay o determinePlay should return an integer and take no arguments o determinePlay should first ask if the user wants to play the game. You can use console input with a Scanner, or a JOptionPane InputDialog. If the user wants to play, determinePlay should prompt the user for the number of times they want to roll dice, between 3 and 5. If invalid input is O provided, prompt the user of their error and try again until receiving valid input. o After getting the number of times the dice will be rolled, the method should return that number. o If the user doesn't want to play, return -1 to quit, as shown in the provided main method • playGame a. playGame should have no return type b. playGame should take the number of times the dice will be rolled as an argument c. playGame should use a method called rollDice to roll two dice d. rollDice should be called and checked, as many times as the user specified, using a for loop e. In the dice ever match, the game should end with the player's victory f. If none of the rolls match, the game should end with the player's loss g. This method MUST use System.exit(0) to end the program when the user has won or lost rollDice a. rollDice takes no argument b. rollDice should roll two dice using the Random object (that is, generate two numbers between 1 and 6, both inclusive) c. If the dice match, the player wins and the playGame method should terminate the program. Note that this function is invoked in the playGame function. d. It is up to you to choose what return type rollDice has – it should be clear whether or not the dice matched through whatever return value you use. (f) Feel free to add more methods, if you feel a need for it. For example, you could have a method to get the random dice roll value. (a) Create a Java class named RiskyDice (b) For this lab, I am providing you with the main method, as shown here: public static void main(String[] args) { int pg = determine Play() ; if (pg != -1) { playGame (pg); } } (c) Above the main method, create a Random object. Make it a public static object, so that we can use it in any of our methods. (d) For this lab, we are making a dice game. You must first prompt the user for whether or not they wish to play the game. If the user does not want to play, exit. Otherwise, your program must simulate rolling a pair of dice between 3 to 5 times, as specified by the user. If the user specifies a number of rolls below 3, or above 5, you must re-prompt the user until they provide an appropriate number of rolls. After the rolls are complete, a single match means the user wins, otherwise the computer wins. (e) Your program needs the following methods that perform the following actions: determinePlay o determinePlay should return an integer and take no arguments o determinePlay should first ask if the user wants to play the game. You can use console input with a Scanner, or a JOptionPane InputDialog. If the user wants to play, determinePlay should prompt the user for the number of times they want to roll dice, between 3 and 5. If invalid input is O provided, prompt the user of their error and try again until receiving valid input. o After getting the number of times the dice will be rolled, the method should return that number. o If the user doesn't want to play, return -1 to quit, as shown in the provided main method • playGame a. playGame should have no return type b. playGame should take the number of times the dice will be rolled as an argument c. playGame should use a method called rollDice to roll two dice d. rollDice should be called and checked, as many times as the user specified, using a for loop e. In the dice ever match, the game should end with the player's victory f. If none of the rolls match, the game should end with the player's loss g. This method MUST use System.exit(0) to end the program when the user has won or lost rollDice a. rollDice takes no argument b. rollDice should roll two dice using the Random object (that is, generate two numbers between 1 and 6, both inclusive) c. If the dice match, the player wins and the playGame method should terminate the program. Note that this function is invoked in the playGame function. d. It is up to you to choose what return type rollDice has – it should be clear whether or not the dice matched through whatever return value you use. (f) Feel free to add more methods, if you feel a need for it. For example, you could have a method to get the random dice roll value.
Expert Answer:
Answer rating: 100% (QA)
Heres the implementation of the RiskyDice class based on the provided requirements java import javau... 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
-
Braum Dairy produces milk to sell to local and national ice cream producers. Braum Dairy began operations on January 1, 2015 by purchasing 650 milk cows for P780,000. The company controller had the...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Identify the process evaluation article that you chose and explain why you selected this example. Describe the purpose of the evaluation, the informants, the questions asked, and the results of the...
-
A project is proposed to design a database for shops selling dairy products. Each shop has a unique ID, name, address and owner. Different shops could be owned by the same owner. Each shop sells...
-
In Problems 1-3, solve each differential equation? 1. Y" - 5y' + 6y = 0 2. Y" + 5y' - 6y = 0 3. Y" + 6y' - 7y = 0; y = 0, y' = 4 at x = 0
-
At its December 31, 2016, year-end, Athletic Apparel had a warehouse with an adjusted book value of $292,500 and an estimated remaining useful life of 15 years and residual value of $90,000. Because...
-
What is the formula for calculating equity per share?
-
a. In the accompanying diagram (which represents the market for chocolate candy bars), the initial equilibrium is at the intersection of S1 and D1. Circle the new equilibrium if there is an increase...
-
8 00 D oints 01:29:06 eBook Following are transactions for Vitalo Company. Nov. 1 Accepted a $18,000, 180-day, 9% note from Kelly White in granting a time extension on her past-due account...
-
Tuckered Outfitters plans to market a custom brand of packaged trail mix. The ingredients for the trail mix will include Raisins, Grain, Chocolate Chips, Peanuts, and Almonds costing, respectively,...
-
1. When the coronavirus pandemic shut down businesses across the nation, sisters Angela Mubwezi-Hall and Deborah Gladney decided it was the perfect time to start a new one. It was an idea they had...
-
A hierarchical way of associating host names with IP addresses is known as: a ARP: b DNS; c RARP; d IP; interface can carry traffic of multiple VLANs. a Access ports b Network ports c Trunk ports d...
-
2 The following contains information about April's production for Cabinera, Incorporated. 3 4 Units produced 10,000 5 Units sold 9,000 5 6 Sales price $450.00 7 Direct materials cost per unit $104.00...
-
Assuming Fermi charge distribution p(r) = Po prove that the skin thickness in which the (r-R2). 1+exp{ a nuclear charge density p(r) falls from 0.9 p, to 0.1 p. is given by t = 4.4 a where p is the...
-
Affordable Lawn Care, Incorporated, provides lawn - mowing services to both commercial and residential customers. The company performs adjusting entries on a monthly basis, whereas closing entries...
-
An analysis of the accounts of Marin Company reveals the following manufacturing cost data for the month ended June 30, 2022. Inventory Beginning Ending Raw materials $9,800 $14,380 Work in process...
-
What role does technology play in shaping contemporary forms of social interaction, communication, and identity construction within virtual spaces?
-
Wal-Mart is the second largest retailer in the world. The data file on the disk holds monthly data on Wal-Marts revenue, along with several possibly related economic variables. a) Using computer...
-
Write a program that inserts 25 random integers from 0 to 100 in order into a linked-list object. For this exercise, youll need to modify the List class (Fig. 21.3) to maintain an ordered list. Name...
-
Some people want to eliminate sexism in all forms of communication. Youve been asked to create a program that can process a paragraph of text and replace gender-specific words with gender-neutral...
-
Write a recursive method recursiveMinimum that determines the smallest element in an array of integers. The method should return when it receives an array of one element.
-
Indicate which type of data analytics, 1 through 4, is described in each of the following statements, a through \(h\). Data Analytics 1. Descriptive analytics 2. Diagnostic analytics 3. Predictive...
-
Match each item in the value chain, 1 through 7 , with an impact of an artificial intelligence initiative, choosing from items a through g. Value Chain 1. Research and development 2. Design 3. Supply...
-
Indicate whether the following items, a through j, are (1) typical characteristics of open-book management or (2) not typical characteristics of open-book management. a. Considered a large size...
![Mobile App Logo](https://dsd5zvtm8ll6.cloudfront.net/includes/images/mobile/finalLogo.png)
Study smarter with the SolutionInn App