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 110 111 112 113 114 115 116 117 118
|
#include <iostream>
#include <string>
#include <sstream>
#include <cstring>
#include <iomanip>
using namespace std;
class player
{
private:
char Firstname[20];
char Lastname[20];
float FTA;//free throw attemps
float FTM;//free throw made
float FGA;//field goals attemps
float FGM;//field goals made
float FTP;//free percentage
float FGP;//field goals percentage
float R,A,S,B,G;//rebound, assist, steals, blocks, games
float RPG;//rebound per game
float PPG;//points per game
float SPG;//steal per game
float APG;//assist per game
float BPG;//block shots per game
void calgradeaverage(void);
public:
void setData(float a, float b, float c, float d, float e, float f, float g, float h, float i); //public function members
player (float a = 1, float b = 1, float c = 1, float d = 1,float e = 1,float f = 1,float g = 1, float h = 1, float i = 1) {setData(a,b,c,d,e,f,g,h,i);}//default constructor
// player(char name[]) {
//strcpy (Firstname, name);
//}
//void setName (char name[]) {strcpy (Firstname, name);}
//char getFirstname (void) {return Firstname[20];}
//char getLastname (void) {return Lastname[20];}
//char[] getFname() const { return Firstname; }
float getFTP() {return (FTM/FTA)*100;}
float getFGP() {return (FGM/FGA)*100;}
float getPPG() {return (FGM*2 + FTM)/G;}
float getRPG() {return (R/G);}
float getAPG() {return (A/G);}
float getBPG() {return (B/G);}
float getSPG() {return (S/G);}
~player(void) {cout<<"bye bye!\n";}
};
void player::setData(float a, float b, float c, float d, float e, float f, float g, float h, float i)
{
FTA = ((a>=0) ? a : 0);
FTM = ((b>=0) ? b : 0);
FGA = ((c>=0) ? c : 0);
FGM = ((d>=0) ? d :0);
R = ((e>=0) ? e :0);
A = ((f>=0) ? f :0);
S = ((g>=0) ? g :0);
B= ((h>=0) ? h :0);
G = ((i>=0) ? i :0);
};
int main()
{
float a, b, c, d,e,f,g,h,i;
char fname;
char lname;
cout<<"please enter FTA ";
cin>>a;
cout<<"please enter FTM ";
cin>>b;
cout<<"please enter FGA ";
cin>>c;
cout<<"please enter FGM ";
cin>>d;
cout<<"please enter rebounce ";
cin>>e;
cout<<"please enter assist ";
cin>>f;
cout<<"please enter staels ";
cin>>g;
cout<<"please enter blocks ";
cin>>h;
cout<<"please enter how many games he played";
cin>>i;
cout<<endl;
player keith;
keith.setData(a,b,c,d,e,f,g,h,i);
cout<<fixed<<setprecision(1);
cout<<"the player's free throw percentage is"<<keith.getFTP()<<"%"<<endl;
cout<<"the player's field goal percentage is"<<keith.getFGP()<<"%"<<endl;
cout<<"the player's points per game is "<<keith.getPPG()<<endl;
cout<<"the player assist per game is " <<keith.getAPG()<<endl;
cout<<"the player's steals per game is" <<keith.getSPG()<<endl;
cout<<"the player's blocked shots per game is" <<keith.getBPG()<<endl;
cin.get();
}
//steals per game, and blocked shots per game. The two shooting percentages are computed by dividing shots made by shots attempted and multiplying by 100. The per game averages are computed by dividing the raw statistic
|