Hello! I am having trouble on how to write out the Java code based on the instructions (//***) that I am given. As a note, this specific Java code is a code that is going to setup the basic framework for a game of Yahtzee. In other words, you will need to understand the rules of Yahtzee and implement the rules into coding. I appreciate the help. Thanks! Also, I am using the IntelliJ IDEA application when writing out this program. I also included some code above the instructions so that you know what to help with here. Here is what I need help with (in bold): do {      System.out.println();      System.out.println(REROLL_MESSAGE_1);      System.out.println();      System.out.println(REROLL_MESSAGE_2);      System.out.println(REROLL_MESSAGE_3);      System.out.println(REROLL_MESSAGE_4);      System.out.println();      System.out.printf(REROLL_MESSAGE_5, (MAX_NUMBER_ROLLS - numberOfRolls));      System.out.println();      System.out.println();      System.out.print(REROLL_MESSAGE_6);      dice2Reroll = input.nextLine().trim();      switch (dice2Reroll.toUpperCase()) {            case 'X':                    turnOver = true;                    gameExit = true;                    break;            case 'S':                    displayScoreSheet();                    break;            case 'D':                    displayDice();                    break;            case '0':                    turnOver = true;                    break;            case "":                    displayErrorMessage();                    break;            default:                   dice2Reroll = dice2Reroll.replace(target:" ", replacement:"");                   String checkDice2Reroll = dice2Reroll;                   checkDice2Reroll = checkDice2Reroll.replaceFirst(regex:"1", replacement:" ");                   checkDice2Reroll = checkDice2Reroll.replaceFirst(regex:"2", replacement:" ");                   checkDice2Reroll = checkDice2Reroll.replaceFirst(regex:"3", replacement:" ");                   checkDice2Reroll = checkDice2Reroll.replaceFirst(regex:"4", replacement:" ");                   checkDice2Reroll = checkDice2Reroll.replaceFirst(regex:"5", replacement:" ");                   if (checkDice2Reroll.isBlank()) {                       for (int i = 0; i < dice2Reroll.length(); i++) {                            die2Reroll = dice2Reroll.charAt(i);                            switch (die2Reroll) {                                  case '1':                                  die1 = generator.nextInt(MAX_NUMBER_ON_DIE) + 1;                                  break;                                  case '2':                                  die2 = generator.nextInt(MAX_NUMBER_ON_DIE) + 1;                                  break;                                  case '3':                                  die3 = generator.nextInt(MAX_NUMBER_ON_DIE) + 1;                                  break;                                  case '4':                                  die4 = generator.nextInt(MAX_NUMBER_ON_DIE) + 1;                                  break;                                  case '5':                                  die5 = generator.nextInt(MAX_NUMBER_ON_DIE) + 1;                                  break;                            }                       }                       numberOfRolls++;                       displayDice();                        if (numberOfRolls == MAX_NUMBER_ROLLS)                            turnOver = true;                   }                  else {                         displayErrorMessage();                  }      } } while (!turnOver); //*** //*** INSTRUCTIONS FOR CODE FOR YOU TO WRITE //*** //*** 1) Write the if-statement-expression for the if-statement; where it says if () { is where it begins. //***      A) The expression must use the correct Java syntax for "not gameExit". //***      B) "not" must be translated to the correct Java Boolean Operator. //***      C) "gameExit" is a boolean variable. //*** 2) Code block for if-statement in Step 1: //***     A) Call method "displayScoreSheet" passing no arguments. //***     B) Define three variables of boolean datatype named: //***         a) "isValidEntry" //***         b) "categoryPicked" //***         c) "continuePrompting" //***         NOTE: These variables do not need to be initialized here, just declared. //***     C) Code block for do-while loop starting on do {: //***          a) Write a statement that assigns the value of true to the variable "isValidEntry". //***          b) Write a statement that assigns the value of false to the variable "categoryPicked". //*** //*** Insert the if-statement-expression from Step 1 into this if-statement. //*** if () {     //***     //*** Insert code for Step 2A here.     //***     //***     //*** Insert code for Step 2B here.     //*** do {     //***     //*** Insert code for Step 2C here.     //***

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Hello! I am having trouble on how to write out the Java code based on the instructions (//***) that I am given. As a note, this specific Java code is a code that is going to setup the basic framework for a game of Yahtzee. In other words, you will need to understand the rules of Yahtzee and implement the rules into coding. I appreciate the help. Thanks! Also, I am using the IntelliJ IDEA application when writing out this program. I also included some code above the instructions so that you know what to help with here. Here is what I need help with (in bold):

do {

     System.out.println();
     System.out.println(REROLL_MESSAGE_1);
     System.out.println();

     System.out.println(REROLL_MESSAGE_2);
     System.out.println(REROLL_MESSAGE_3);
     System.out.println(REROLL_MESSAGE_4);

     System.out.println();
     System.out.printf(REROLL_MESSAGE_5, (MAX_NUMBER_ROLLS - numberOfRolls));
     System.out.println();

     System.out.println();
     System.out.print(REROLL_MESSAGE_6);

     dice2Reroll = input.nextLine().trim();

     switch (dice2Reroll.toUpperCase()) {

           case 'X':
                   turnOver = true;
                   gameExit = true;
                   break;

           case 'S':
                   displayScoreSheet();
                   break;

           case 'D':
                   displayDice();
                   break;

           case '0':
                   turnOver = true;
                   break;

           case "":
                   displayErrorMessage();
                   break;

           default:

                  dice2Reroll = dice2Reroll.replace(target:" ", replacement:"");

                  String checkDice2Reroll = dice2Reroll;

                  checkDice2Reroll = checkDice2Reroll.replaceFirst(regex:"1", replacement:" ");
                  checkDice2Reroll = checkDice2Reroll.replaceFirst(regex:"2", replacement:" ");
                  checkDice2Reroll = checkDice2Reroll.replaceFirst(regex:"3", replacement:" ");
                  checkDice2Reroll = checkDice2Reroll.replaceFirst(regex:"4", replacement:" ");
                  checkDice2Reroll = checkDice2Reroll.replaceFirst(regex:"5", replacement:" ");

                  if (checkDice2Reroll.isBlank()) {

                      for (int i = 0; i < dice2Reroll.length(); i++) {

                           die2Reroll = dice2Reroll.charAt(i);

                           switch (die2Reroll) {

                                 case '1':
                                 die1 = generator.nextInt(MAX_NUMBER_ON_DIE) + 1;
                                 break;

                                 case '2':
                                 die2 = generator.nextInt(MAX_NUMBER_ON_DIE) + 1;
                                 break;

                                 case '3':
                                 die3 = generator.nextInt(MAX_NUMBER_ON_DIE) + 1;
                                 break;

                                 case '4':
                                 die4 = generator.nextInt(MAX_NUMBER_ON_DIE) + 1;
                                 break;

                                 case '5':
                                 die5 = generator.nextInt(MAX_NUMBER_ON_DIE) + 1;
                                 break;

                           }

                      }

                      numberOfRolls++;

                      displayDice();

                       if (numberOfRolls == MAX_NUMBER_ROLLS)
                           turnOver = true;
                  }

                 else {
                        displayErrorMessage();
                 }

     }

} while (!turnOver);

//***
//*** INSTRUCTIONS FOR CODE FOR YOU TO WRITE
//***
//*** 1) Write the if-statement-expression for the if-statement; where it says if () { is where it begins.
//***      A) The expression must use the correct Java syntax for "not gameExit".
//***      B) "not" must be translated to the correct Java Boolean Operator.
//***      C) "gameExit" is a boolean variable.
//*** 2) Code block for if-statement in Step 1:
//***     A) Call method "displayScoreSheet" passing no arguments.
//***     B) Define three variables of boolean datatype named:
//***         a) "isValidEntry"
//***         b) "categoryPicked"
//***         c) "continuePrompting"
//***         NOTE: These variables do not need to be initialized here, just declared.
//***     C) Code block for do-while loop starting on do {:
//***          a) Write a statement that assigns the value of true to the variable "isValidEntry".
//***          b) Write a statement that assigns the value of false to the variable "categoryPicked".

//***
//*** Insert the if-statement-expression from Step 1 into this if-statement.
//***
if () {
    //***
    //*** Insert code for Step 2A here.
    //***

    //***
    //*** Insert code for Step 2B here.
    //***

do {
    //***
    //*** Insert code for Step 2C here.
    //***

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY