Maurice Tutor

(5)

$15/per page/Negotiable

About Maurice Tutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Algebra,Applied Sciences See all
Algebra,Applied Sciences,Biology,Calculus,Chemistry,Economics,English,Essay writing,Geography,Geology,Health & Medical,Physics,Science Hide all
Teaching Since: May 2017
Last Sign in: 398 Weeks Ago, 1 Day Ago
Questions Answered: 66690
Tutorials Posted: 66688

Education

  • MCS,PHD
    Argosy University/ Phoniex University/
    Nov-2005 - Oct-2011

Experience

  • Professor
    Phoniex University
    Oct-2001 - Nov-2016

Category > Management Posted 28 Sep 2017 My Price 10.00

PASS BY VALUE FUNCTIONS

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 FUNCTION

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 hareA????1s selection was passed as the second parameter, harePicked. The return value is the number of eggs that the Tortoise selects. Hint: After the hare picks, if the tortoise makes a selection so that the sum of both picks is 4, then the tortoise will always be the winner, since 12 is evenly divisible by 4.

There is the Lab3 13 eggs problem,

13 eggs problem.cpp

#include <iostream>

using namespace std;
int main()
{

   // Use of a flag to control the game
   // The program plays the role of the "Judge" for the game
   // - program askes for a valid selection
   // - program determines if the game is over
   // - program declares the winner

   bool gameOver = false; // flag
   int numberEggs = 13;
   int player = 1; // 1 for Tortoise , 2 for Hare
   int selected;
   while (!gameOver)
   {
       cout << "Enter your selection " << (player == 1 ? "Tortoise" : "Hare") << " ";
       cin >> selected;
       // If move is legal: 1 to 3 eggs and no more than numEggs remaining

       if (selected <= 3 && selected >= 1 && numberEggs >= selected) // student supplies code
       {
           numberEggs -= selected; // student supplies code

           if (numberEggs > 0) // student supplies code
           {
               player = (player % 2) + 1; // student supplies code
           }
           else
           {
               gameOver = true;
           }
       }
       else // not a valid selection
       {
           cout << "Not a valid egg selection, try again\n";
       }
   } // end while

   //declare the winner
   cout << "Winner is " << (player == 1 ? "Tortoise" : "Hare") << endl;
   // student supplies code

   return 0;

} // end main

Answers

(5)
Status NEW Posted 28 Sep 2017 10:09 PM My Price 10.00

Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll

Not Rated(0)