Got a code failiure. I tried making a code that does this. Grade calculator. Assume max points are 300. make the user submit 3 numbers between 0-100 and have them added together and divided by 300 to get a decimal to the possible nearest Hundredth or whole number. 3 numbers are basically grades of the 0-100 points.
I don't expect anyone to be on this late, and I have an entire 3 days left for this code.
I use Dev-Cpp Bloodshed
My code fails by
Ex: 1st grade 15, 2nd 15, 3rd 15. add together gets 45. then divide by 300 should get .15. but what i get with my code is 151515Press any key to continue . . .
My code is this
//Michael Nicodemus
//Ch2 Program
#include <cstdlib>
#include <iostream>
#include <math.h>
using namespace std;
void in(double & S1, double & S2, double & S3);
double ave(double & S1, double & S2, double & S3, double & PP);
int out(int S1, int S2, int S3, double Grade);
int main()
{ double g1, g2, g3;
cout<<"enter a grade 0-100"<<endl;
cin>>g1;
cout<<"enter a grade 0-100"<<endl;
cin>>g2;
cout<<"enter a grade 0-100"<<endl;
cin>>g3;
cout<<g1<<g2<<g3;
system("PAUSE");
return 0;
}
void in(double & S1, double & S2, double & S3)
{ cout<<"enter a grade"<<endl;
cin>>S1;
cout<<"enter a grade"<<endl;
cin>>S2;
cout<<"enter a grade"<<endl;
cin>>S3;
cout<<S1<<S2<<S3;
}
double ave(double & S1, double & S2, double & S3)
{
double PP;
PP=S1+S2+S3;
return (PP);
}
int out(int S1, int S2, int S3, double Grade)
{ Grade=(S1+S2+S3)/300;
return (Grade);
cout<<"Your grade is"<<Grade<<endl;
}