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

You will be creating a simple two-dimensional predator-prey simulation. In this

ID: 3603266 • Letter: Y

Question

You will be creating a simple two-dimensional predator-prey simulation. In this simulation the prey are ants and the predators are doodlebugs. These critters live in a world composed of a 20 x20 grid of cells. Only one critter may occupy a cell at a time. The grid is enclosed, so a critter is not allowed to move off the edges of the world. Time is simulated in time steps. Each critter performs some action every time step. Doodlebugs eat Ants. 2 The ants behave according to the following model Move. Every time step, randomly try to move up, down, left, or right. (hints: you can use a random number generator to generate integer from 1 to 4, 1-right, 2-down, 3 = left, and 4 -up). If the neighboring cell in the selected direction is occupied or would move the ant off the grid, then the ant stays in the current cell Breed. If an ant survives for three time steps, then at the end of the time step (that is after moving) the ant will breed. This is simulated by creating a new ant in an adjacent (up, down, left, or right) cell that is empty. If there is no empty cell available, then no breeding occurs. Once an offspring is produced, an ant cannot produce an offspring until three more time steps have elapsed The doodlebugs behave according to the following model

Explanation / Answer

//EXAMPLE PROGRAM FOR MULTIPLE INHERITANCE AND PROTECTED

//MEMBERS

//TWO OR MORE BASE CLASSES ONE DERIVED CLASS IS CALLED

//MULTIPLE INHERITANCE

# include <iostream.h>

# include <conio.h>

class employ

{

protected:

int eno,bs;

char name[20],eadd[20];

public:

void input()

{

cout<<"ENTER EMPLOY NUMBER, NAME, ADDRESS, BASIC SALARY ";

cin>>eno>>name>>eadd>>bs;

}

};

class allowance

{

protected:

int da,hra,cca;

public:

void accept()

{

cout<<"ENTER DA, HRA, CCA "<<endl;

cin>>da>>hra>>cca;

}

};

class deduction

{

protected:

int pf,it;

public:

void dedinput()

{

cout<<"ENTTER PF,IT "<<endl;

cin>>pf>>it;

}

};

class salary : public employ,public allowance,

public deduction

{

int tall,tded,gs,ns;

public:

void calc_sal()

{

tall=da+hra+cca;

tded=pf+it;

gs=bs+tall;

ns=gs-tded;

}

void output()

{

cout<<"EMPLOY NUMBER "<<eno<<endl;

cout<<"EMPLOY NAME "<<name<<endl;

cout<<"EMPLOY ADDRESS "<<eadd<<endl;

cout<<"BASIC SALARY "<<bs<<endl;

cout<<"DA IS "<<da<<endl;

cout<<"HRA IS "<<hra<<endl;

cout<<"CCA IS "<<cca<<endl;

cout<<"PF IS "<<pf<<endl;

cout<<"IT IS "<<it<<endl;

cout<<"TOTAL ALLOWANCES "<<tall<<endl;

cout<<"TOTAL DEDUCTIONS "<<tded<<endl;

cout<<"GROSS SALARY IS "<<gs<<endl;

cout<<"NET SALARY IS "<<ns<<endl;

}

};

void main()

{

salary s;

clrscr();

s.input(); //MEMBER FUNCTION OF EMPLOY CLASS

s.accept(); //MEMBER FUNCTION OF ALLOWANCE CLASS

s.dedinput(); //MEMBER FUNCTION OF DEDUCTION CLASS

clrscr();

s.calc_sal(); //MEMBER FUNCTION OF SALARY CLASS

s.output();

getch();

}

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