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 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
|
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <math.h>
#include "baseball.h"
using namespace std;
/* float calcip(double fpart);
float getera(int runs, float ip);
float calcbavg(int hits,int atbats);
int calctotal_bases(int single,int doubles,int triples,int homeruns);
int getnumsingles(int hits,int doubles,int triples,int homeruns);
int calctotal_hits(int single,int doubles,int triples,int homeruns);
float calc_slugper(int atbats, int totalbases);
float calc_sbper(int steals, int total_sba);
int calc_totsba(int steals, int caughtsteal);*/
int main()
{
double fpart;
int runs,end,hits,atbats, doubles,triples,homeruns,single;
int totalbases,totalhits, steals, caughtsteal, total_sba;
float era, ip, fpt, bavg, slugper, sbper;
end=9;
do
{
cout << "Enter the numbers of runs allowed ";
cin >> runs;
cout << "\n";
cout << "Enter the number of innings pitched ";
cin >> ip;
cout << "\n";
fpart=ip;
ip=calcip(fpart);
era=getera(runs,ip);
cout << "Enter the number of at bats " ;
cin >> atbats;
cout << "\n";
cout << "Enter the number of hits ";
cin >> hits;
cout << "\n";
bavg=calcbavg(hits,atbats);
cout << "Enter the number of doubles ";
cin >> doubles;
cout << "\n";
cout <<"enter the number of triples ";
cin >> triples;
cout <<"\n";
cout <<"Enter the number of home runs ";
cin >>homeruns;
cout <<"\n";
cout<<"Enter the number of stolen bases "<<"\n";
cin >>steals;
cout<<"\n";
cout <<"Enter the number of time caught stealing "<<"\n";
cin>>caughtsteal;
cout<<"\n";
total_sba=calc_totsba(steals,caughtsteal);
sbper=calc_sbper(steals,total_sba);
single=getnumsingles(hits,doubles,triples,homeruns);
totalbases=calctotal_bases(single,doubles,triples,homeruns);
totalhits=calctotal_hits(single,doubles,triples,homeruns);
slugper=calc_slugper(atbats,totalbases);
cout <<"The number of at bats = "<<atbats<<"\n";
cout <<"The number of hits = "<<hits<<"\n";
cout <<"The numbe of singles = "<<single<<"\n";
cout <<"The number of doubles = "<<doubles<<"\n";
cout <<"The numbe of triples= "<<triples<<"\n";
cout <<"the number of home runs = "<<homeruns<<"\n";
cout << "The batting average = " << setprecision(3)<< bavg << "\n";
cout << "The number of Total Bases = " << totalbases <<"\n";
cout<<"The number of total stolen base attempts = "<<total_sba<<"\n";
cout <<"Totalhits= " << totalhits << "\n";
cout << " The earned run average = "<< fixed <<setprecision(2) << era;
cout << "\n";
cout<<" the Slugging Percentage = "<<fixed<<setprecision(3)<<slugper<<"\n";
cout<<"The stolen base percentage = "<<fixed<<setprecision(2)<<sbper<<"\n";
cout << " Enter 0 to quit or anything else to continue ";
cout <<"\n";
cin >> end;
}while (end > 0);
return 0;
}
/* float getera(int rs, float i)
{
float er;
er=(rs*9)/i;
return er;
}
float calcip(double fpt)
{
double ipt,fcpt,param;
param=fpt;
fcpt = modf (param , &ipt);
if ((fcpt > .0) && (fcpt <=.1))
{
param=ipt+.3333;
fpt=param;
}
else
if ((fcpt >.1) &&(fcpt <.21))
{
param=ipt+.6666;
fpt=param;
}
else
{
param=ipt+.0000;
fpt=param;
}
return fpt;
}
float calcbavg(int hit,int ab)
{
float ba;
ba=float(hit)/float(ab);
return ba;
}
int calctotal_bases(int s,int d,int t,int hr)
{
int tb;
tb=s+(d*2)+(t*3)+(hr*4);
return tb;
}
int getnumsingles(int h,int d,int t,int hr)
{
int s;
s=h-(d+t+hr);
return s;
}
int calctotal_hits(int s,int d,int t, int hr)
{
int th;
th=s+d+t+hr;
return th;
}
float calc_slugper(int ab, int tb)
{
float sp;
sp=float(tb)/float(ab);
return sp;
}
float calc_sbper(int sb, int t_sba)
{
float sper;
sper=float(sb)/float(t_sba);
return sper;
}
int calc_totsba(int sb, int cs)
{
int tsb;
tsb=sb+cs;
return tsb;
}
*/
|