+3 votes
in Class 12 by kratos

Define a class to represent batsmen in a cricket team. Include the following members: Data Members: First name, Last name, Runs made, Number of fours, Number of sixes Member Functions:

(i) To assign the initial values

(ii) To update runs made (It should simultaneously update fours and sixes, if required).

(iii) To display the batsman’* information Make appropriate assumptions about access labels.

1 Answer

+1 vote
by kratos
 
Best answer

include

include

include

class Batsman

{

char F_Name[30];

char L_Name[30];

int Runs_made,fours,sixes;

public:

void initial()

{

cout<<end1<<"Enter Frist Name :";

gets (F-Name);

cout<<end1<<"Enter Last Name :";

gets (L-Name);

cout<<end1<<"Enter Runs Made :;

cout<>Runs_made;

cout<<end1<<"Enter how many fours :";

cout<>fours;

cout<<end1<<"Enter how many sixes :";

cout<>sixes;

}

void update()

{

int new_run,new_four,new_sixes,cal_four,cal_six;

cout<<end1<<"Enter new runs Made:";

cout<>new_run;

cout<<end1<<"Enter new fours Made:";

cout<>new_four;

cout<<end1<<"Enter new sives Made:";

cin>>new_sixes;

fours=fours+new_four; sixes=sixes+new_sixes;

cal_four=fours4; cal_six=sixes6;

Runs_made=Runs_made+new_run+cal_four+cal_six;

display();

cout<<"Total Runs Made: "<<Runs_made<<end1;

cout<<"Number of fours: "<<fours<<end1;

cout<<"Number of sixes: "<<sixes<<end1;

}

void display() {

cout<<".....Batsman'* information....."<<end1;

cout<<"Name: "<<F_Name<<" "<<L_Name<<end1;

}

};

void main() {

clrscr();

Batsman b1;

b1.initial();

b1.update();

getch();

}

...