mitkonikov

Untitled

Mar 21st, 2023
624
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. class BasketballPlayer {
  6.     string firstname, lastname;
  7.     int dres;
  8.     int first_contest, second_contest, third_contest;
  9.  
  10. public:
  11.     BasketballPlayer(string fn, string ln, int d, int c1, int c2, int c3) {
  12.         firstname = fn;
  13.         lastname = ln;
  14.         dres = d;
  15.         first_contest = c1;
  16.         second_contest = c2;
  17.         third_contest = c3;
  18.     }
  19.  
  20.     double average() {
  21.         return (double)(first_contest + second_contest + third_contest) / 3;
  22.     }
  23.  
  24.     void print() {
  25.         cout << "Player: " << firstname << " " << lastname << " with number: " << dres << " has " << average() << " points on average";
  26.     }
  27. };
  28.  
  29. int main() {
  30.     string firstname, lastname;
  31.     int dres, c1, c2, c3;
  32.     cin >> firstname >> lastname >> dres >> c1 >> c2 >> c3;
  33.     BasketballPlayer player(firstname, lastname, dres, c1, c2, c3);
  34.     player.print();
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment