## np2100

I am still just a beginner and i made this average program. It worked out just fine. THen i decided I wanted to make it say like the grade you got such as an A+ or C. Anyway after I add all the grades and divide them by the number of grades I want to store the average as a variable "average" and then use the if/else statements. Any help will be appreciated.

``````#include <iostream>
using namespace std;

int main()
{
system("TITLE Averager");
system("COLOR 2f");
int average;

if ( > 97.5)
cout<<"You got an A+";

system("pause");
return 0;
}``````

## np2100

I know my code is bad however my problem is that after i average the grades i want to store that average as a variable. Ive tried doing (gradea + gradeb + gradec + graded + gradee + gradef)/6= average and cin>>average but i cant it doesnt work. Any alternatives??

## joshua.tilson 3

if ( > 97.5)
cout<<"You got an A+";

try this

``````int average;
if (average  > 97.5)
cout<<"You got an A+";
``````

Good Luck!

## vmanes 1,165

I know my code is bad however my problem is that after i average the grades i want to store that average as a variable. Ive tried doing (gradea + gradeb + gradec + graded + gradee + gradef)/6= average and cin>>average but i cant it doesnt work. Any alternatives??

Basic rule: Left Hand Side (LHS) is assigned the Right Hand Side (RHS). So, your average computation must be

``average = (gradea + gradeb + gradec + graded + gradee + gradef)/6;``

Further, since your grades and you divisor are all of type int, the result of the division will be of type int. You will not get a fractional value. Change the divisor to 6.0, and you will get a fractional value. Variable average must be declared as a floating point type, either float or double.

Now that you have an average, your statement to display the grade:

``````if ( > 97.5)
cout<<"You got an A+";``````

can be corrected. As it stands, what is being compared to 97.5? Your compiler should have given an error on that line. Pay attention to the error and warning messages.

Val

## np2100

Thanks that helped a lot