Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. class batsman
  4. {
  5. int batsman_code;
  6. string batsman_name;
  7. int total_innings, notout_innings, total_runs;
  8. float batting_avg;
  9. float calcavg()
  10. {
  11. float c=(float)total_runs/(float)(total_innings-notout_innings);
  12. return c;
  13.  
  14.  
  15.  
  16. }
  17. public:
  18. void display_data(){
  19.  
  20. cout<<"output"<<endl;
  21. cout<<"batsman code : ";
  22. cout<<batsman_code<<endl;
  23. cout<<"enter batsman_name : ";
  24. cout<<batsman_name<<endl;
  25. cout<<"total_inings "<<total_innings<<endl<<"notout_inings ";
  26. cout<<notout_innings<<endl<<"total_runs "<<total_runs<<endl;
  27. cout<<"bating average "<<calcavg()<<endl;
  28.  
  29.  
  30. }
  31. void read_data(){
  32.  
  33. cout<<"input "<<endl;
  34. cout<<"enter batsman code : ";
  35. cin>>batsman_code;
  36. cout<<"enter batsman_name : ";
  37. cin>>batsman_name;
  38. cout<<"enter total_inings ";
  39. cin>>total_innings;
  40. cout<<"notout_innings ";
  41. cin>>notout_innings;
  42. cout<<"total_runs ";
  43. cin>>total_runs;
  44.  
  45. }
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53. };
  54. int main()
  55. {
  56.  
  57. batsman a1;
  58. a1.read_data();
  59. a1.display_data();
  60.  
  61.  
  62.  
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement