Can someone please help me with the following coding given based on the instructions (//*** in bold)? I am not sure on how to go about it here. Just as a side note, this is coding that is going to be used for a working Yahtzee program. I am also using the IntelliJ IDEA application for this code. Thanks for the help! public static int calculateYahtzee() { int score = 0; boolean isYahtzee = true; //*** //*** INSTRUCTIONS FOR CODE FOR YOU TO WRITE //*** //*** 1) Replace this if-statement structure with the code in Steps 2 & 3: //*** //*** if (die1 == die2 && die2 == die3 && die3 == die4 && die4 == die5) //*** isYahtzee = true; //*** //*** 2) In place of the code in Step 1, write a for-loop that iterates ("number of dice" - 1) times. //*** //*** 3) Code block for the for-loop in Step 2: //*** A) Using the for-loop's control variable as an index into array variable "dice", write an if-statement that checks the value of each element in the array variable "dice" for "inequality to" the next element in array variable "dice". //*** B) If the condition in Step 3A evaluates to true, then assign the value of false to variable "isYahtzee". //*** //*** NOTE: 1) Array variable "dice" replaces all of the individual die variables (e.g. die1, die2, etc). //*** 2) You are replacing the if-statement structure that uses the individual die variables with a for-loop that contains a nested if-statement structure that references into array variable "dice". //*** //*** This can be as few as three lines of code not including any curly braces. //***
Can someone please help me with the following coding given based on the instructions (//*** in bold)? I am not sure on how to go about it here. Just as a side note, this is coding that is going to be used for a working Yahtzee program. I am also using the IntelliJ IDEA application for this code. Thanks for the help!
public static int calculateYahtzee() {
int score = 0;
boolean isYahtzee = true;
//***
//*** INSTRUCTIONS FOR CODE FOR YOU TO WRITE
//***
//*** 1) Replace this if-statement structure with the code in Steps 2 & 3:
//***
//*** if (die1 == die2 && die2 == die3 && die3 == die4 && die4 == die5)
//*** isYahtzee = true;
//***
//*** 2) In place of the code in Step 1, write a for-loop that iterates ("number of dice" - 1) times.
//***
//*** 3) Code block for the for-loop in Step 2:
//*** A) Using the for-loop's control variable as an index into array variable "dice", write an if-statement that checks the value of each element in the array variable "dice" for "inequality to" the next element in array variable "dice".
//*** B) If the condition in Step 3A evaluates to true, then assign the value of false to variable "isYahtzee".
//***
//*** NOTE: 1) Array variable "dice" replaces all of the individual die variables (e.g. die1, die2, etc).
//*** 2) You are replacing the if-statement structure that uses the individual die variables with a for-loop that contains a nested if-statement structure that references into array variable "dice".
//***
//*** This can be as few as three lines of code not including any curly braces.
//***
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images