Reminder: Formatting is always important in your code (comments, indentation, variable names, etc.) And please always...
Fantastic news! We've Found the answer you've been seeking!
Question:
![image.png](https://dsd5zvtm8ll6.cloudfront.net/questions/2024/05/6639177853f95_1715017456537.jpg)
![image.png](https://dsd5zvtm8ll6.cloudfront.net/questions/2024/05/66391777988fd_1715017455632.jpg)
Transcribed Image Text:
Reminder: Formatting is always important in your code (comments, indentation, variable names, etc.) And please always start your Java code file with a multi-line comment listing the name of the developer, the date of completion and a short description of the program. And you must document each method. 1 Yahtzee If you have never played Yahtzee before, you can go play now at: http://www.yahtzeeonline.org/ Yahtzee is a game where the objective is to score points by rolling five dice to make certain combinations. The dice can be rolled up to three times in a turn to try to make various scoring combinations. A game consists of thirteen rounds. In each round, a player gets three rolls of the dice, although they can choose to end their turn after one or two rolls. After the first roll the player can save any dice they want and re-roll the other dice. This procedure is repeated after the second roll. The player has complete choice as to which dice to roll. They could re-roll a die for the third roll that was not rolled on the second roll. The Yahtzee scorecard contains 13 different category boxes and in each round, after the third roll, the player must choose one of these categories. The score entered in the box depends on how well the five dice match the scoring rule for the category. Details of the scoring rules for each category are given below. As an example, one of the categories is called Three-of-a-Kind. The scoring rule for this category means that a player only scores if at least three of the five dice are the same value. The game is completed after 13 rounds are played, with each of the 13 boxes being filled. The total score is calculated by summing all thirteen boxes, together with any bonuses. The following table demonstrates the Yahtzee Scorecard Category What the dice must be Score Aces Any combo Twos Any combo Threes Fours Fives Sixes Any combo Any combo Any combo Any combo 3 of a kind 4 of a kind Full House Small Straight Large Straight Yahtzee Chance At least 3 dice the same At least 4 dice the same 3 of a kind + 2 of a kind Four sequential dice Sum of dice with value 1 Sum of dice with value 2 Sum of dice with value 3 Sum of dice with value 4 Sum of dice with value 5 Sum of dice with value 6 Sum of all 5 dice Sum of all 5 dice 25 Example Roll 1 1 1 34 scores 3 22256 scores 6 3 3 3 3 4 scores 12 4 4 5 5 5 scores 8 11225 scores 5 23666 scores 18 2 3 4 4 4 scores 17 4 5 5 5 5 scores 24 22 5 5 5 scores 25 30 1 3 4 5 6 scores 30 5 sequential dice All 5 dice the same 40 50 Any combo Sum of all 5 dice 1 2 3 4 5 scores 40. 22222 scores 50 113 55 scores 15 1.1 Sample Output See the Yahtzee.pdf document on brightspace for an example of sample output of this assignment 2 1.2 Game Setup [25 points] To design your program: 1. Inside the main method of your class, create two integer arrays, one of size five to represent the dice being rolled, and one of size 13 to represent the scorecard. 2. Write the method void rollDice (int[] diceArray) that sets each element in the dice array to be a random number between 1 and 6 inclusive. 3. Write the method void reroll (int[] diceArray) This method should first read the number of dice the user would like to reroll, then allow the user to specify the index(es) of which dice to reroll. Now we will need to create some methods to help us fill in the score card. 4. Write the method int sumAllDice (int[] dice) that sums up the total of all the dice currently in the array and returns the sum 5. Write the method int sumOf Dice (int[] dice, int faceValue) that sums up all of the dice that have a value of faceValue. So for example calling sumOf Dice (new int[] 1,2,3,3,1, 3) would return 6. 6. Write the method void scoreDice (int () scorecard, int () dice, int category) category represents the user's selection of which category they want to score the dice for (ex. three of a kind, small straight, etc.). The method should then store the correct total in the scorecard for the given state of the dice. Note that for some categories (Yahtzee, straight, etc.) your method should store a default value, for some categories (3 of a kind, chance, etc.) your method should store the sum of all the dice, and for others (aces, twos, etc.) your method should store the sum of some of the dice. 7. Write a method called int totalScore (int[] scoreCard) that sums up the total score of all the scores stored in the score card array. So far our program assumes the user will play the game properly and not try to cheat. Let's implement some methods to check and make sure the user isn't cheating! 8. Implement a method that checks to make sure that the user isn't trying to score a category in the score card that has already been scored (i.e., stop the user from scoring 3 of a kind more than once) 1.3 Main Method [10 points] Write the main method to allow the user to play a game of Yahtzee. The main program should allow the user to take 13 turns, and on each turn the following actions should happen: 1. roll all 5 dice 2. display the dice 3. allow the user to reroll any number of dice, no more than three times 4. allow the user to choose which item on the scorecard to fill 5. display the score card 6. When the last turn has finished, display the total sum of the scorecard. 3 Reminder: Formatting is always important in your code (comments, indentation, variable names, etc.) And please always start your Java code file with a multi-line comment listing the name of the developer, the date of completion and a short description of the program. And you must document each method. 1 Yahtzee If you have never played Yahtzee before, you can go play now at: http://www.yahtzeeonline.org/ Yahtzee is a game where the objective is to score points by rolling five dice to make certain combinations. The dice can be rolled up to three times in a turn to try to make various scoring combinations. A game consists of thirteen rounds. In each round, a player gets three rolls of the dice, although they can choose to end their turn after one or two rolls. After the first roll the player can save any dice they want and re-roll the other dice. This procedure is repeated after the second roll. The player has complete choice as to which dice to roll. They could re-roll a die for the third roll that was not rolled on the second roll. The Yahtzee scorecard contains 13 different category boxes and in each round, after the third roll, the player must choose one of these categories. The score entered in the box depends on how well the five dice match the scoring rule for the category. Details of the scoring rules for each category are given below. As an example, one of the categories is called Three-of-a-Kind. The scoring rule for this category means that a player only scores if at least three of the five dice are the same value. The game is completed after 13 rounds are played, with each of the 13 boxes being filled. The total score is calculated by summing all thirteen boxes, together with any bonuses. The following table demonstrates the Yahtzee Scorecard Category What the dice must be Score Aces Any combo Twos Any combo Threes Fours Fives Sixes Any combo Any combo Any combo Any combo 3 of a kind 4 of a kind Full House Small Straight Large Straight Yahtzee Chance At least 3 dice the same At least 4 dice the same 3 of a kind + 2 of a kind Four sequential dice Sum of dice with value 1 Sum of dice with value 2 Sum of dice with value 3 Sum of dice with value 4 Sum of dice with value 5 Sum of dice with value 6 Sum of all 5 dice Sum of all 5 dice 25 Example Roll 1 1 1 34 scores 3 22256 scores 6 3 3 3 3 4 scores 12 4 4 5 5 5 scores 8 11225 scores 5 23666 scores 18 2 3 4 4 4 scores 17 4 5 5 5 5 scores 24 22 5 5 5 scores 25 30 1 3 4 5 6 scores 30 5 sequential dice All 5 dice the same 40 50 Any combo Sum of all 5 dice 1 2 3 4 5 scores 40. 22222 scores 50 113 55 scores 15 1.1 Sample Output See the Yahtzee.pdf document on brightspace for an example of sample output of this assignment 2 1.2 Game Setup [25 points] To design your program: 1. Inside the main method of your class, create two integer arrays, one of size five to represent the dice being rolled, and one of size 13 to represent the scorecard. 2. Write the method void rollDice (int[] diceArray) that sets each element in the dice array to be a random number between 1 and 6 inclusive. 3. Write the method void reroll (int[] diceArray) This method should first read the number of dice the user would like to reroll, then allow the user to specify the index(es) of which dice to reroll. Now we will need to create some methods to help us fill in the score card. 4. Write the method int sumAllDice (int[] dice) that sums up the total of all the dice currently in the array and returns the sum 5. Write the method int sumOf Dice (int[] dice, int faceValue) that sums up all of the dice that have a value of faceValue. So for example calling sumOf Dice (new int[] 1,2,3,3,1, 3) would return 6. 6. Write the method void scoreDice (int () scorecard, int () dice, int category) category represents the user's selection of which category they want to score the dice for (ex. three of a kind, small straight, etc.). The method should then store the correct total in the scorecard for the given state of the dice. Note that for some categories (Yahtzee, straight, etc.) your method should store a default value, for some categories (3 of a kind, chance, etc.) your method should store the sum of all the dice, and for others (aces, twos, etc.) your method should store the sum of some of the dice. 7. Write a method called int totalScore (int[] scoreCard) that sums up the total score of all the scores stored in the score card array. So far our program assumes the user will play the game properly and not try to cheat. Let's implement some methods to check and make sure the user isn't cheating! 8. Implement a method that checks to make sure that the user isn't trying to score a category in the score card that has already been scored (i.e., stop the user from scoring 3 of a kind more than once) 1.3 Main Method [10 points] Write the main method to allow the user to play a game of Yahtzee. The main program should allow the user to take 13 turns, and on each turn the following actions should happen: 1. roll all 5 dice 2. display the dice 3. allow the user to reroll any number of dice, no more than three times 4. allow the user to choose which item on the scorecard to fill 5. display the score card 6. When the last turn has finished, display the total sum of the scorecard. 3
Expert Answer:
Answer rating: 100% (QA)
This program solves all the questions import javautilRandom import javautilScanner public class Yahtzee public static void mainString args int dice new int5 Array to represent the five dice int scorec... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these operating system questions
-
(Weighted average cost of capital) The target capital structure for Jowers Manufacturing is 50 percent common stock, 16 percent preferred stock, and 34 percent debt. If the cost of common equity for...
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all 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...
-
The following set of dotplots with overlaid boxplots gives the number of pairs of flip-flops students said they owned for 13 males (top) and 37 females (bottom) in a statistics class. The five-number...
-
Explain how a pension fund might use a long hedge with stock-index futures
-
If the unit selling price is $16, the unit variable cost is $12, and fixed costs are $160,000, what are the break-even sales (units)? A. 5,714 units B. 10,000 units C. 13,333 units D. 40,000...
-
Read the story Footprints. How does this relate to creativity? To leadership? To providing leadership and fostering creativity in nursing?
-
An electrical resistor is connected to a battery, as shown schematically. After a brief transient, the resistor assumes a nearly uniform, steady-state temperature of 95C, while the battery and lead...
-
The Prince-Robbins partnership has the following capital account balances on January 1, 2021: Prince, Capital Robbins, Capital $ 150,000 140,000 Prince is allocated 60 percent of all profits and...
-
The ____ attempts to take components of various theories and build a single explanation that incorporates the best parts of the individual theories. learning approach elaboration model expansion...
-
Hypothesis testing and testing claims with confidence intervals are two different approaches that lead to the same conclusion. In the following activities, you will compare and contrast those two...
-
The following system of periodic tasks is scheduled and executed according to a cyclic schedule. Draw an execution trace (timeline) showing two occurances of each task. Ti ei Pi 1 8 T2 4 15 T3 3 20...
-
n1 = 20, n2 = 25, S = 607, H1: 1 2. In Exercises 710, compute S, S, and the value of the test statistic z. Then find the P-value for the specified alternate hypothesis and values of n1, n2, and S.
-
To determine whether traffic levels differ between the morning and evening rush hours, a traffic engineer counted the number of cars passing through a certain intersection during five-minute periods...
-
Macon Timber Company established a \(\$ 150\) petty cash fund on January 1, 2012. Required a. Is the establishment of the petty cash fund an asset source, use, or exchange transaction? b. Record the...
-
A trucking company determined that the distance traveled per truck per year is normally distributed, with a mean of 60 thousand miles and a standard deviation of 12 thousand miles. Complete parts (a)...
-
The graph of an equation is given. (a) Find the intercepts. (b) Indicate whether the graph is symmetric with respect to the x-axis, the y-axis, or the origin. -3 6 -6 3 x
-
Texts or calls? Refer to Exercise 91. A boxplot of the difference (texts calls) in the number of texts and calls for each student is shown below. (a) Do these data support the claim in the article...
-
Acing the first test Here are the scores of Mrs. Liaos students on their first statistics test: 93 93 87.5 91 94.5 72 96 95 93.5 93.5 73 82 45 88 80 86 85.5 87.5 81 78 86 89 92 91 98 85 82.5 88 94.5...
-
Dont call me In a September 28, 2008, article titled Letting Our Fingers Do the Talking, the New York Times reported that Americans now send more text messages than they make phone calls. According...
![Mobile App Logo](https://dsd5zvtm8ll6.cloudfront.net/includes/images/mobile/finalLogo.png)
Study smarter with the SolutionInn App