Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- class BasketballPlayer {
- string firstname, lastname;
- int dres;
- int first_contest, second_contest, third_contest;
- public:
- BasketballPlayer(string fn, string ln, int d, int c1, int c2, int c3) {
- firstname = fn;
- lastname = ln;
- dres = d;
- first_contest = c1;
- second_contest = c2;
- third_contest = c3;
- }
- double average() {
- return (double)(first_contest + second_contest + third_contest) / 3;
- }
- void print() {
- cout << "Player: " << firstname << " " << lastname << " with number: " << dres << " has " << average() << " points on average";
- }
- };
- int main() {
- string firstname, lastname;
- int dres, c1, c2, c3;
- cin >> firstname >> lastname >> dres >> c1 >> c2 >> c3;
- BasketballPlayer player(firstname, lastname, dres, c1, c2, c3);
- player.print();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment