Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Modify the 13 eggGame problem from Lab 3. Ask the user whether they want to go f

ID: 669804 • Letter: M

Question

Modify the 13 eggGame problem from Lab 3. Ask the user whether they

want to go first or whether the computer (Tortoise) should go first. In

itialize player

variable to 1 or 2 accordingly.

Write a function that makes the selection for the Tortoise. The prototype

for the function is:

int tortoisePick(int numberEggs)

There is a strategy that you can use so that the Tortoise always wins.

When

the function is called: if numberEggs divided by 4 (integer

division), gives a remainder that is not zero, that is the number the

computer (Tortoise) should select. Otherwise, the computer (Tortoise)

should select 1 to give the user (Hare) the maximum o

pportunity to make a

mistake.

The return value is the number of eggs that the Tortoise selects.

Explanation / Answer

01       #include 02 using namespace::std; 03 int tortoisePick (int, int); 04 05 int tortoisePick (int numberEggs, int harePicked) 06 { 07     int pick = 0; 08 09     if (numberEggs == 13) 10         pick == 1; 11     else if (numberEggs!= 13) 12         harePicked; 13     else if (harePicked == 2) 14         pick == 2; 15     else 16         pick ==3; 17 18     return pick; 19 } 20 21 22 23 24 25 void main() 26 { 27     bool gameOver = false; // flag 28     int numberEggs = 13; 29     int player = 1;         // 1 for Tortoise ,   2 for Hare 30     int selected; 31     int hareSelect =0; 32     while( !gameOver ) 33     {   34         cout =1 && selected
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote