1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
#include <iostream>
#include <cmath>
using namespace std;
class football
{
public:
string n, t;
int interception, td, yrd, PR;
double a, b, c, d, comp, att, w;
public:
void input() {
// cout << "Input the player's name and the team he plays for\n.";
// getline (cin, n );
// getline (cin, t );
cout << "Input the player's attempts and completion" << endl;
cin >> att;
cin >> comp;
cout << "Input the player's Tds and interceptions ." << endl;
cin >> td;
cin>> interception;
cout << "Input the player's yards gained in the season ." << endl;
cin >> yrd;
}
void playerspass() {
cout << " The QB has " << att << " attepts on the season with "<< comp << " completed for a pass " << endl;
}
void TDandInts() {
cout << " "<< n << "had " << td <<" touchdowns" << " and " << interception << " interceptions on the season" << endl;
}
void yrds() {
cout << " the Qb had " << yrd << " in the season " << endl;
}
void firsta(){
a= ((comp/att) -.3)*5;
cout<< a << endl;
}
void firstb(){
b=((yrd/att)-3)*.25;
cout<< b << endl;
}
void firstc(){
c=(td/att)*20;
cout<< c << endl;
}
void passerating(){
w= ((a+b+c+d)/6)*100;
cout<<" the QB's rating is " << w << endl;
}
void firstd(){
d= 2.375-((interception/att)*25);
cout<< d << endl;
}
};
void comparePlayers (football f,football g ,double firstPlayer, double secondPlayer);
int main()
{
football f, g; // Creating object of class
string n, t, n1, t1;
cout << "Input the player's name and the team he plays for\n.";
getline (cin, n );
getline (cin, t );
f.input();
//f.playername();
cout << " the QBs name is " << n << " and he plays for the " << t << endl;
f.TDandInts();
f. playerspass();
f.yrds();
f.firsta();
f.firstb();
f.firstc();
f.firstd();
f.passerating();
cout << "Input the player's name and the team he plays for\n.";
getline (cin, n1 );
getline (cin, t1 );
g.input();
// g.playername();
cout << " the QBs name is " << n << " and he plays for the " << t << endl;
g.TDandInts();
g.playerspass();
g.yrds();
g.firsta();
g.firstb();
g.firstc();
g.firstd();
g.passerating();
comparePlayers ( f, g ,f.w, g.w);
return 0;
}
void comparePlayers (football f,football g ,double firstPlayer, double secondPlayer)
{
string firstName, secondName;
firstName = f.n;
secondName = g.n;
if ( f.w > g.w) {
cout<< firstName << " had the higher passer rating." << endl;
}
else{
cout<< secondName << " had the higher passer rating." << endl;
}
}
|