Hello,
I'm having trouble getting my program to send back accurate values. It works, but is inaccurate, especially with values of 10 or 1000. If I have grade 1 equal to 10 and the rest of the values to 100 the result will still be 54 instead of 51.3. What do I have wrong?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include <iostream>
usingnamespace std;
int main ()
{
double x, a, bgrade;
cout << "BASAL Gradebook:" << endl;
for (x = 1; x <= 18; x++)
{
cout << " Enter BASAL grade #" << x << " (out of 100): ";
cin >> a;
bgrade = 3 * (a / 100) * 18;
}
cout << "BASAL points earned: " << bgrade << endl;
cout << endl;
}
bgrade is replaced every time you go round the loop, so if the last grade entered is 100, the result will be 54. The previous 17 results have no effect.