Dec 10, 2015

program to accept cricket player statastics

#include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<iomanip.h>
class cricket
{
char name[30];
float truns;
float tmat;
float avg;
public:
void get_data();
void put_data();
};
void cricket::get_data()
{
cout<<"Enter the player name : ";
cin>>name;
cout<<"\n Enter the total run of the player "<<name<<endl;
cin>>truns;
cout<<"\n Enter the total matches played by "<<name<<endl;
cin>>tmat;
avg=truns/tmat;
}
void cricket::put_data()
{
cout.setf(ios::left,ios::adjustfield);
cout<<setw(10)<<name<<"\t"<<setw(10)<<truns<<"\t"<<setw(10)<<tmat<<"\t"<<setw(10)<<"\t"<<"\t"<<avg<<endl;

}
void main()
{
clrscr();
int n;
cricket c[' '];
cout<<"Enter the num of player :";
cin>>n;
for(int i=1;i<=n;i++)
{
cout<<"Enter the details of player "<<i<<endl;
c[i].get_data();
}
clrscr();
cout<<"----------------------------------------------------------"<<endl;
cout<<"player-Name \t Total-runs \t Total-Matches \t tbatting avg \n";
cout<<"----------------------------------------------------------"<<endl;
for(i=1;i<=n;i++)
{
c[i].put_data();
}
cout<<"----------------------------------------------------------"<<endl;
getch();
}

No comments:

Post a Comment