How the game works: The computer will roll the dice and display them to the scre
ID: 3772616 • Letter: H
Question
How the game works: The computer will roll the dice and display them to the screen. The user will decide which to keep and which to recoll The computer will roll the dice a second time and display them to the screen. The user will decide which to keep and which to rero! The computer will roll the dice a third time and display them to the screen. The computer will display the scorecard The computer will ask the user which line they want to score their turn on, the user will enter it The computer will determine the appropriate score to place on the selected line The computer will display the updated scorecard The computer will start a new turn The computer will continue this way until the scorecard is completely full. Scorecard should look something like this: Line I Upper Section I Score I Ones Twos I Threes l Fours Fives 15 I Sixes I Subtotal I 21 I Bonus I Upper Section 21 Lower Section 7 Three of a Kind 122 8 Four of a Kind 9 Full House I 25 10 I Small Straight 11 Large Straight I 40 12 I Yahtzee 13 Chance Lower Section I 87 I Total I 108
Explanation / Answer
#include #include #include using namespace std; int main () { int rand ( void ); int dice[5]; int turn; char reroll[5]; dice[0]=rand() % 6+1; dice[1]=rand() % 6+1; dice[2]=rand() % 6+1; dice[3]=rand() % 6+1; dice[4]=rand() % 6+1; turn=1; while (turn"Turn #" "Your first roll is: " " (Type 'y' to re-roll or 'n' to stay)"; cin >> reroll[0] >> reroll[1] >> reroll[2] >> reroll[3] >> reroll[4]; if (reroll[0]='y'){ dice[0]=rand() % 6+1;} if(reroll[0]='n'){ dice[0];} if (reroll[1]='y'){ dice[1]=rand() % 6+1;} if (reroll[2]='y'){ dice[2]=rand() % 6+1;} if (reroll[3]='y'){ dice[3]=rand() % 6+1;} if (reroll[4]='y'){ dice[4]=rand() % 6+1;} cout "Your second Roll is " " (Type 'y' to re-roll or 'n' to stay)"; dice[0]=rand() % 6+1; dice[1]=rand() % 6+1; dice[2]=rand() % 6+1; dice[3]=rand() % 6+1; dice[4]=rand() % 6+1; turn++;} return 0; }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.