Question: 1) Declare a double pointer. Allocate new memory for it and assign it a value of 36.7. Remember, you are assigning a value to the

1) Declare a double pointer. Allocate new memory for it and assign it a value of 36.7. Remember, you are assigning a value to the memory location, don't assign 36.7 as the address! 2) Complete the following program as instructed in the comments int kidsAge=11, *papaAge, *familyAges[2]; //a) dynamically allocate an int and assign the location to papaAge papaAge= __________________________________________; //b) Assign 35 to papaAge (the value 35, NOT the memory location 35!) ___________________ = 35; //c) Assign element 0 of familyAges to papaAge ____________________________ = papaAge; //d) Assign element 1 of familyAges to address of kidsAge __________________________________________________; //e) Write code to efficiently add 5 to every element of familyAges (that is, the value of kidsAge should be 16, and papaAge 40. _____________________________________________ _____________________________________________ _____________________________________________ _____________________________________________ 3) Make a proper function call using only the variables defined below as arguments. Note that you may need to modify the variables with the operators used in processing pointers, but you must use one of the 3 variables listed below. Also note that you should not try to guess at the implementation of the functions, all you are doing is calling the function properly. int i=6; double *doub = new double; char* exclaim="I've got game!"; a) void yourGame(char ); b) void myScore(double *, int); c) void myGoodness(char *); d) void earlyTime(int); e) void lateTime(int*, char*, double, double* ); f) void e(double);

4) Create the following class. You will NOT need setters and getters for this. There will however be 1 constructor as indicated.

class BallGame

{

public:

string homeTeam;

string awayTeam;

int homeScore;

int awayScore;

BallGame(string hmTeam, string awTeam, int hmSc, int awSc);

bool didHomeTeamWin();

};

You must implement the constructor and didHomeTeamWin() method. The method must return whether the home team has the larger score. (Note, a tie is not a win)

In main:

Allocate memory for three separate BallGame instances and point to that memory with 3 separate pointer variables, game1, game2, and game3. Make each pointer represent the following data:

"Mystics", "Fire", 100,92

"Capitals", "Lightning", 2,3

"Ravens", "Colts",35,35

5)

Write a FUNCTION, NOT a method that will accept a pointer to a BallGame instance as shown in number 4.

The function must return void and output a message accoding to the parameter.

if the parameter's didHomeTeamWin() returns true, output the message:

Home team won against away team

If the parameter's didHomeTeamWin() returns false, output:

Home team lost against away team

where home team and away team are the values held in the instance.

The function must be named showResults.

6) In main, call the showResults() function for game1, game2, and game3 one at a time like:

showResults(game1);

showResults(game2);

showResults(game3);

Deallocate memore from game1, game2, game3

See template below:

#include

using namespace std;

//Create your class

class BallGame

{

public:

string homeTeam;

string awayTeam;

int homeScore;

int awayScore;

//You must implement the constructor and the method.

//You may implement inline

BallGame(string ht, string at, int hmSc, int awSc);

bool didHomeTeamWin();

};

//You can implement constructor and method here if you like

//Implement showResults() function here.

int main()

{

//Declare and instantiate game1, game2, and game3

//Call the function once's for each BallGame instance

showResults(game1);

showResults(game2);

showResults(game3);

//deallocate the memory for game1, game2, game3

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!