Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(60) A score of sixty may indicate a failure to read instructions carefully. The user input for re-rolls is ordered (and ordered left to
(60) A score of sixty may indicate a failure to read instructions carefully. The user input for re-rolls is ordered (and ordered left to right). A re-roll input of 123 says roll the 1 then the 2 then the 3. It matters. Otherwise if the second input is 1 or 3 you will be rolling the die the tester is trying to keep. (5) A score of 5 likely has multiple problems but one of them is that you are not ending the turn on input of 0. Instead you have read the input for the next turn as the second re-roll input. You program will run out of input and probably reuse an old input value. (15) A score of 15 may indicate a problem with scoring rolls like 16266. I've seen this a few times now. (70) A score of 70 means you aren't ending the turn on 0 for the first re-roll. UPDATE: (0) COMMON PROBLEM: If you are getting a score of 5 or 15 you are probably not ending the turn after a zero on the first reroll. If the user enters a zero there will be no input for a second reroll on that turn. If you read that will be the input for the next turn. And you will run out of input. Scanf will start to fail so the input variable will not change. This is why you may still get the first test correct. Your program will believe seven additional zeros were supplied as input. On one of the tests you may get the scores right until a zero is offered on the first reroll. The input will be out of synch after that. This was listed as IMPORTANT in the instructions under interface. (1) XahtC.-- rolling the dice . Use the expression (rand() %6+1) to simulate a roll of the dice. o cand() is a function that generates a random positive integer. %6 modulates the random integer into a range 0.5 +1 makes the range 16 just like a dice is expected. In the tester I make use of the fact that I can control the random numbers generated -- do not call and more than required or the numbers you use will not be the numbers expected to be generated by the tester. Do not call seed again. This will result in a different than expected set of numbers. (2) YahtC.-- rerolling the dice (2) YahtC -- rerolling the dice When the user chooses to reroll the reroll needs to happen in order left to right If the user rerolls: 135, first roll die 1 then die 3 then die 5. (#1 PROBLEM IN STUDENT SUBMISSIONS) Otherwise if we reroll only 3 or 5 on the last try we won't be rolling the same die. . . (3) An error in Test case 7 Test case 7 was missing some input. This has been corrected. You do not have to resubmit if you received the point already anyway. (4) Library differences You are not guaranteed the Zybooks rand() is the same as your rand() just as we may have difference with strcmp() (some libraries always return -1, 0, 1, some don't). Welcome to YahtC YahtC is a dice game (very) loosely modeled on Yahtzee(tm) BUT YahtC is not Yahtzee(tm). Rules of YahtC: 5 dice are rolled The user selects which dice to roll again. The user may choose to roll none or all 5 or any combination. And then the user selects which dice to roll, yet again. After this second reroll the turn is scored. Scoring is as follows: 50 points 5 of a kind scores 50 points. . 45 points No pairs (all unique) scores 45 points. 40 points 4 of a kind scores 40 points. 30 points 3 of a kind scores 30 points. Total Dice Otherwise score the dice total. Interface: To indicate nothing to reroll the user will input 0 o This should end the players turn. You must use the template. The code in the template must remain. Specifically int main(int arge, char * argv) { seed (arge, argu); will be required for correct scoring. The seed function will set the random number generator to specific sequences that can be repeated. The template will also provide a function that prints the game rules instructions but it's presence or absence will not affect grading. Example Run: Below I present a full example run. Your prompts during game play may vary slightly (the input should remain the same). /a.out Ak Welcome to YahtC + ********* . ********** YahtC is a dice game (very) loosely modeled on Yahtzee BUT YahtC is not Yahtzee. Rules: 5 dice are rolled The user selects which dice to roll again. The user may choose to roll none or all 5 or any combination. And then the user selects which dice to roll, yet again. After this second reroll the turn is scored. Scoring is as follows: 50 points 5 of a kind scores 50 points. * 45 points No pairs (all unique) scores 45 points. 40 points 4 of a kind scores 40 points. 30 points 3 of a kind scores 30 points. Total Dice Otherwise score the dice total. To indicate nothing to reroll the user will input 0 This should end the players turn. Otherwise the user will indicate which dice to reroll by position 135 would indicate to reroll the first, third and last die. The numbers do not have to be given in order The game ends after 7 turns. ** First Roll = 24512 Select dice to reroll:1 second: 64512 Select dice to reroll:0 score for 64512 is 45 First Roll = 25665 Select dice to reroll:1 second: 55665 Select dice to reroll:34 final: 55515 score for 55515 is 40 First Roll = 55224 Select dice to reroll:5 second: 55221 Select dice to rerol1:5 final:55222 score for 55222 is 30 First Roll = 26566 Select dice to rero11:13 second: 36466 Select dice to reroll:13 final: 36566 score for 36566 is 30 First Roll 21511 Select dice to reroll:13 second: 11311 Select dice to rero11:3 final:11311 score for 11311 is 40 First Roll = 51411 Select dice to rero11:13 second: 61211 Select dice to reroll: 13 final:61511 score for 61511 is 30 First Roll 44154 Select dice to reroll:34 second: 44434 Select dice to reroll:4 final: 44464 score for 44464 is 40 ---------- SCORESHEET -------- Turn 1: 45 Turn 2: 40 Turn 3: 30 Turn 4: 30 Turn 5: 40 Turn 6: 30 Turn 7: 40 ======= Total: 255
Step by Step Solution
★★★★★
3.46 Rating (156 Votes )
There are 3 Steps involved in it
Step: 1
It seems like youre discussing a dice game and the importanc...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started