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

I have a lab due that I don\'t understand how to write. I\'m new to programming

ID: 641649 • Letter: I

Question

I have a lab due that I don't understand how to write. I'm new to programming and my online teacher is no help. Heres the questions I don't understand how do I proram this using VC++.

PASS BY VALUE FUNCTIONS

1.Modify the 13 eggs problem from Lab 3.

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

int tortoisePick(int numberEggs, int harePicked)

There is a strategy that you can use so that the Tortoise always wins. When the function is called, if numberEggs is equal to 13, the tortoise is making the first selection. If numberEggs is not equal to 13, the hare has made a selection and the hare

Explanation / Answer

#include <iostream>
using namespace::std;
int tortoisePick(int numberOfEggs);

void main()
{
bool gameOver = false; // flag
int numberEggs = 13;
int player = 0; // 1 for Tortoise , 2 for Hare
int selected;
cout << "Would you like to go first or second? " << endl;

cin >> player;

if (player==1)
player = 2;
else
player = 1;


while( !gameOver )
{

cout << "Number of eggs remaining is " << numberEggs << endl;
if (player == 2){

cout << "Enter your selection (1, 2 or 3) "
<< (player==1 ? "Tortoise":"Hare") << " ";
cin >> selected;
}
else{
selected = tortoisePick(numberEggs);
cout << "The computer picked: " << selected << endl;
}


int tortoisePick(int numberOfEggs)
{
int result;

if( (numberOfEggs %4) !=0 )
result = (numberOfEggs%4);
else
result = 1;

return result;
}