#include<iostream>
using namespace std;
class baseball{
double bat_avg;
public:
int calcbatavg(double hitsnum, double at_bats){bat_avg=(hitsnum/at_bats);}
int printavg(){return bat_avg;}
};
int main(){
baseball calc;
double bathits, atbats;
cout << "Enter number of hits\n";
cin >> bathits;
cout << "Enter number of atbats\n";
cin >> atbats;
calc.calcbatavg(bathits, atbats);
cout << "The batting average is: " << calc.printavg();
system("pause");
return 0;
}
now when I run this code I get all the results fine. But however the double type is not working. What I mean by that is the results are not showing decimal points, I tried this with float too but the same error. Ususally the answers are rounded. Any help would be appreciated thank you.:)


Sign In
Create Account

Back to top









