Yahtzee program.
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!
//***
//*** INSTRUCTIONS FOR CODE FOR YOU TO WRITE
//***
//*** 1) Replace these six if-else structures with the code in Steps 2 & 3:
//***
//*** if (aces == SCORE_NO_VALUE)
//*** System.out.println(FIRST_OPTION_LABEL + OPTION_SUFFIX_ONE_DIGIT + ACES_LABEL);
//*** else
//*** System.out.println(FIRST_OPTION_LABEL + OPTION_SUFFIX_ONE_DIGIT + ACES_LABEL + EQUALS_LABEL + aces);
//***
//*** if (twos == SCORE_NO_VALUE)
//*** System.out.println(SECOND_OPTION_LABEL + OPTION_SUFFIX_ONE_DIGIT + TWOS_LABEL);
//*** else
//*** System.out.println(SECOND_OPTION_LABEL + OPTION_SUFFIX_ONE_DIGIT + TWOS_LABEL + EQUALS_LABEL + twos);
//***
//*** if (threes == SCORE_NO_VALUE)
//*** System.out.println(THIRD_OPTION_LABEL + OPTION_SUFFIX_ONE_DIGIT + THREES_LABEL);
//*** else
//*** System.out.println(THIRD_OPTION_LABEL + OPTION_SUFFIX_ONE_DIGIT + THREES_LABEL + EQUALS_LABEL + threes);
//***
//*** if (fours == SCORE_NO_VALUE)
//*** System.out.println(FOURTH_OPTION_LABEL + OPTION_SUFFIX_ONE_DIGIT + FOURS_LABEL);
//*** else
//*** System.out.println(FOURTH_OPTION_LABEL + OPTION_SUFFIX_ONE_DIGIT + FOURS_LABEL + EQUALS_LABEL + fours);
//***
//*** if (fives == SCORE_NO_VALUE)
//*** System.out.println(FIFTH_OPTION_LABEL + OPTION_SUFFIX_ONE_DIGIT + FIVES_LABEL);
//*** else
//*** System.out.println(FIFTH_OPTION_LABEL + OPTION_SUFFIX_ONE_DIGIT + FIVES_LABEL + EQUALS_LABEL + fives);
//***
//*** if (sixes == SCORE_NO_VALUE)
//*** System.out.println(SIXTH_OPTION_LABEL + OPTION_SUFFIX_ONE_DIGIT + SIXES_LABEL);
//*** else
//*** System.out.println(SIXTH_OPTION_LABEL + OPTION_SUFFIX_ONE_DIGIT + SIXES_LABEL + EQUALS_LABEL + sixes);
//***
//*** 2) In place of the code in Step 1, write a for-loop that iterates "number of items in upper section category" times.
//***
//*** Hint: There is a constant already defined for "number of items in upper section category" that you must use.
//***
//*** 3) Code block for the for-loop in Step 2:
//*** A) Using the for-loop's control variable as an index into array variable "scores", write an if-statement that checks the value of each upper category score element in the array variable "scores" for "equality to" SCORE_NO_VALUE.
//*** B) If the condition in Step 3A evaluates to true, then the category has not been used, therefore do the following:
//*** a) Code block if Step 3A evaluates to true:
//*** 1) Write a println statement that displays the menu option using the for-loop's control variable in displaying both the menu number and the associated value in array constant "labels".
//*** b) Code block when Step 3A evaluates to false (else-statement):
//*** 1) Write a println statement that displays the menu option using the for-loop's control variable in displaying: the menu number, the associated value in array constant "labels", and the associated score value stored in array variable "scores".
//***
//*** NOTE: 1) Array variable "scores" replaces all of the individual score variables (e.g. aces, twos, etc).
//*** 2) Array constant "labels" replaces all of the individual label constants (e.g. ACES_LABEL, TWOS_LABEL, etc).
//*** 3) You are replacing the six if-else structures that use the individual score variables with a for-loop that contains a nested if-else structure that references into array variable "scores" and array constant "labels".
//***
//*** This can be as few as five lines of code not including any curly braces.
//***
Trending now
This is a popular solution!
Step by step
Solved in 2 steps