Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- class batsman
- {
- int batsman_code;
- string batsman_name;
- int total_innings, notout_innings, total_runs;
- float batting_avg;
- float calcavg()
- {
- float c=(float)total_runs/(float)(total_innings-notout_innings);
- return c;
- }
- public:
- void display_data(){
- cout<<"output"<<endl;
- cout<<"batsman code : ";
- cout<<batsman_code<<endl;
- cout<<"enter batsman_name : ";
- cout<<batsman_name<<endl;
- cout<<"total_inings "<<total_innings<<endl<<"notout_inings ";
- cout<<notout_innings<<endl<<"total_runs "<<total_runs<<endl;
- cout<<"bating average "<<calcavg()<<endl;
- }
- void read_data(){
- cout<<"input "<<endl;
- cout<<"enter batsman code : ";
- cin>>batsman_code;
- cout<<"enter batsman_name : ";
- cin>>batsman_name;
- cout<<"enter total_inings ";
- cin>>total_innings;
- cout<<"notout_innings ";
- cin>>notout_innings;
- cout<<"total_runs ";
- cin>>total_runs;
- }
- };
- int main()
- {
- batsman a1;
- a1.read_data();
- a1.display_data();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement