In Java. Just fill in the code where it says "/* Complete the method and update the return statement */"please. Program Specifications Write a program to calculate the score from a throw of five dice. Scores are assigned to different categories for singles, three of a kind, four of a kind, five of a kind, full house, and straight. Follow each step to gradually complete all methods. Note: This program is designed for incremental development. Complete each step and submit for grading before starting the next step. Only a portion of tests pass after each step but confirm progress. Step 0. Review the provided main() method. Five integer values are input and inserted into an array. The array is sorted and passed to findHighScore() to determine the highest scoring category. Make no changes to main(). Stubs are provided for all remaining methods. Step 1. Complete the checkSingles() method. Return the sum of all values that match parameter goal. Update the findHighScore() method to use a loop to call checkSingles() six times with parameters of 1 - 6. Return the highest score from all method calls. Submit for grading to confirm two tests pass. Ex: If input is: 2 4 1 5 4 the output is: High score: 8 Step 2. Complete the checkThreeOfKind(), checkFourOfKind(), and checkFiveOfKind() methods. Hint: Since the values are in ascending order, same values are stored in consecutive index locations. Return 30 from checkThreeOfKind() if the dice contain at least three of the same values. Ex: (2, 3, 3, 3, 6). Return 40 from checkFourOfKind() if the dice contain at least four of the same values. Ex: (4, 4, 4, 4, 5). Return 50 from checkFiveOfKind() if the dice contain five identical values. Ex: (5, 5, 5, 5, 5). Update the findHighScore() method to call the three methods and return the highest score from all method calls. Submit for grading to confirm five tests pass. Ex: If input is: 2 4 4 5 4 the output is: High score: 30 Step 3  Complete the checkFullHouse() method to return 35 if the dice contain a full house (a pair and three of a kind). Ex: (1, 1, 3, 3, 3). Note: Five of a kind also satisfies the definition of a full house since (4, 4, 4, 4, 4) includes a pair of 4s and three 4s. Update the findHighScore() method to call checkFullHouse() and return the highest score from all method calls. Submit for grading to confirm seven tests pass. Step 4  Complete the checkStraight() method to return 45 if the dice contain a straight of (1, 2, 3, 4, 5) or (2, 3, 4, 5, 6). Update the findHighScore() method to call checkStraight() and return the highest score from all method calls. Submit for grading to confirm all tests pass. import java.util.Scanner; import java.util.Arrays; public class LabProgram {        public static void main(String[] args) {       Scanner scnr = new Scanner(System.in);       int diceValues[] = new int[5];       int highScore = 0;               // Fill array with five values from input       for(int i=0; i

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

In Java. Just fill in the code where it says "/* Complete the method and update the return statement */"please.

Program Specifications Write a program to calculate the score from a throw of five dice. Scores are assigned to different categories for singles, three of a kind, four of a kind, five of a kind, full house, and straight. Follow each step to gradually complete all methods.

Note: This program is designed for incremental development. Complete each step and submit for grading before starting the next step. Only a portion of tests pass after each step but confirm progress.

Step 0. Review the provided main() method. Five integer values are input and inserted into an array. The array is sorted and passed to findHighScore() to determine the highest scoring category. Make no changes to main(). Stubs are provided for all remaining methods.

Step 1. Complete the checkSingles() method. Return the sum of all values that match parameter goal. Update the findHighScore() method to use a loop to call checkSingles() six times with parameters of 1 - 6. Return the highest score from all method calls. Submit for grading to confirm two tests pass.

Ex: If input is:

2 4 1 5 4

the output is:

High score: 8

Step 2. Complete the checkThreeOfKind(), checkFourOfKind(), and checkFiveOfKind() methods. Hint: Since the values are in ascending order, same values are stored in consecutive index locations. Return 30 from checkThreeOfKind() if the dice contain at least three of the same values. Ex: (2, 3, 3, 3, 6). Return 40 from checkFourOfKind() if the dice contain at least four of the same values. Ex: (4, 4, 4, 4, 5). Return 50 from checkFiveOfKind() if the dice contain five identical values. Ex: (5, 5, 5, 5, 5). Update the findHighScore() method to call the three methods and return the highest score from all method calls. Submit for grading to confirm five tests pass.

Ex: If input is:

2 4 4 5 4

the output is:

High score: 30

Step 3  Complete the checkFullHouse() method to return 35 if the dice contain a full house (a pair and three of a kind). Ex: (1, 1, 3, 3, 3). Note: Five of a kind also satisfies the definition of a full house since (4, 4, 4, 4, 4) includes a pair of 4s and three 4s. Update the findHighScore() method to call checkFullHouse() and return the highest score from all method calls. Submit for grading to confirm seven tests pass.

Step 4  Complete the checkStraight() method to return 45 if the dice contain a straight of (1, 2, 3, 4, 5) or (2, 3, 4, 5, 6). Update the findHighScore() method to call checkStraight() and return the highest score from all method calls. Submit for grading to confirm all tests pass.

import java.util.Scanner;
import java.util.Arrays;

public class LabProgram {
   
   public static void main(String[] args) {
      Scanner scnr = new Scanner(System.in);
      int diceValues[] = new int[5];
      int highScore = 0;
       
      // Fill array with five values from input
      for(int i=0; i<diceValues.length; ++i) {
         diceValues[i] = scnr.nextInt();
      }
      
      // Place values in ascending order
      Arrays.sort(diceValues);
      
      // Find high score and output
      highScore = findHighScore(diceValues);
      System.out.println("High score: " + highScore);
   }

   // Find high score
   public static int findHighScore(int dice[]) {
      /* Complete the method and update the return statement */
      return -1; 
   }
   
   // Add all occurences of goal value
   public static int checkSingles(int dice[], int goal) {
      /* Complete the method and update the return statement */
      return -1;   
   } 
   
   // Check for three of a kind (score = 30)    
   public static int checkThreeOfKind(int dice[]) {
      /* Complete the method and update the return statement */
      return -1;  
   }
   
   // Check for four of a kind (score = 40)    
   public static int checkFourOfKind(int dice[]) {
      /* Complete the method and update the return statement */
      return -1;   
   }   
   
   // Check for five of a kind (score = 50)    
   public static int checkFiveOfKind(int dice[]) {
      /* Complete the method and update the return statement */
      return -1;  
   }        
   
   // Check for full house (score = 35)
   public static int checkFullHouse(int dice[]) {     
      /* Complete the method and update the return statement */
      return -1; 
   } 
   
   // Check for straight (score = 45)    
   public static int checkStraight(int dice[]) {
      /* Complete the method and update the return statement */
      return -1;  
   }   
}

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 7 steps with 6 images

Blurred answer
Knowledge Booster
void method
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education