I need help with my program.I have already started it but can't finish the program.The user is to input three grades and find the average of these three grades.
The original program has a lot of additional code, but it is all based around the variable named grade which is always zero. Perhaps you meant to use the Average there?
I found some ambiguities in the way you represent the scores (if the student scores 90, he gets an A and a B at the same time?) The code below seems to be a little better:
#include <iostream>
usingnamespace std;
int main ()
{
double grade(0.0), grade1(0.0), grade2(0.0), grade3(0.0);
cout<<"Please Enter Grade #1"<<endl;
cin >> grade1 ;
cout<<"Please Enter Grade #2"<<endl;
cin >> grade2 ;
cout<<"Please Enter Grade #3"<<endl;
cin>> grade3 ;
grade = (grade1+grade2+grade3)/3;
if (grade>=90)
cout << "Congrats, your average is: " << grade << ". You got an A" << endl;
elseif (grade<90 && grade>=80)
cout << "Congrats, your average is: " << grade << ". You got an B" << endl;
elseif (grade<80 && grade>=70)
cout << "Congrats, your average is: " << grade << ". You got an C" << endl;
else
cout << "Sorry, your average is: " << grade << ". You got an F" << endl;
return 0;
}