Hello! I am having trouble on how to write out the Java code based on the instructions (in bold //***) 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. Here is what I need help with: * The code given below is going to be modified based on the instructions in bold. public static int calculateUpperSectionCategory(int dieNumber) { int score; score = 0; System.out.println("In method calculateUpperSectionCategory"); return score; } //*** //*** INSTRUCTIONS FOR CODE FOR YOU TO WRITE //*** //*** Modify your "calculateUpperSectionCategory" method as follows: //*** 1) Remove the System.out.println statement. //*** //*** 2) Write an if-statement that checks variable "die1" for //*** "equality to" parameter variable "dieNumber". //*** //*** 3) Code block for if-statement in Step 2: //*** A) Add the value of variable "die1" to the current value of variable "score" and store that //*** value back into variable "score". In other words, accumulate variable "die1" into variable //*** "score". //*** //*** 4) Following the form of the if-statement-block in Step 2 and 3 for variable "die1", write four (4) //*** more if-statement-blocks that check the variables "die2", "die3", "die4" and "die5" for //*** "equality to" parameter variable "dieNumber", and then accumulates the associated "die" //*** variable into variable "score". //*** //*** 5) None of these if-statements have else clauses or are chained with else clauses. They are //*** independent if-statements. //*** //*** 6) Keep the return statement that returns the variable "score".
Hello! I am having trouble on how to write out the Java code based on the instructions (in bold //***) 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. Here is what I need help with:
* The code given below is going to be modified based on the instructions in bold.
public static int calculateUpperSectionCategory(int dieNumber) {
int score;
score = 0;
System.out.println("In method calculateUpperSectionCategory");
return score;
}
//***
//*** INSTRUCTIONS FOR CODE FOR YOU TO WRITE
//***
//*** Modify your "calculateUpperSectionCategory" method as follows:
//*** 1) Remove the System.out.println statement.
//***
//*** 2) Write an if-statement that checks variable "die1" for
//*** "equality to" parameter variable "dieNumber".
//***
//*** 3) Code block for if-statement in Step 2:
//*** A) Add the value of variable "die1" to the current value of variable "score" and store that //*** value back into variable "score". In other words, accumulate variable "die1" into variable //*** "score".
//***
//*** 4) Following the form of the if-statement-block in Step 2 and 3 for variable "die1", write four (4)
//*** more if-statement-blocks that check the variables "die2", "die3", "die4" and "die5" for //*** "equality to" parameter variable "dieNumber", and then accumulates the associated "die" //*** variable into variable "score".
//***
//*** 5) None of these if-statements have else clauses or are chained with else clauses. They are //*** independent if-statements.
//***
//*** 6) Keep the return statement that returns the variable "score".
//***
Trending now
This is a popular solution!
Step by step
Solved in 2 steps