here is my code
ok so when I enter in 87 for all 3 grades and I mention that the person has perfect attendance, it curves the grade and gives him an A. But when I enter in 77 and give him perfect attendance, it doesn't give him a curve, it stays the same and gives him a c.

#include "stdafx.h" // Needed for Visual C++ Express 2010
#include <iostream>
using namespace std;
int main()
{
bool perfectattendance;
perfectattendance= 1;

if (average >= 90)
{
}
else if ((average >= 80) && (average >= 87) && (perfectattendance==1))
{
}
else if ((average >= 80) && (average >= 87) && (perfectattendance==0))
{
cout << "Yourletter grade is a B" << endl;
}
else if ((average >= 70) && (average < 77) && (perfectattendance==1))
{
}
else if ((average >= 70) && (average >= 77) && (perfectattendance==0))
{
}
else if ((average >= 60) && (average < 67) && (perfectattendance==1))
{
}
else if ((average >= 60) && (average < 67) && (perfectattendance==0))
{
}
else if ((average >= 50) && (average < 57) && (perfectattendance==1))
{
}
else if ((average >= 50) && (average < 57) && (perfectattendance==0))
{
cout << "Your letter grade is an F and you failed the class" << endl;
}
cin.ignore(); // needed for Visual C++ Express 2010

return 0;
}
Your code explains everything. You have used if else statements to check the range of the average grade and if it is between 90 and 100, you give him an A, if between 80 and 87, you give him an A and so on.

Notice that the average you calculated is 77, which lies between 70 and 77, and so will give a grade C.
 ``1234`` ``````else if ((average >= 70) && (average >= 77) && (perfectattendance==0)) { cout << "Your letter grade is a C" << endl; }``````

Hope that helps.
@sl227

These are not correct.
 ``123456789101112131415161718192021222324252627282930313233343536`` ``````if (average >= 90) { cout << "Your letter grade is an A" << endl; } else if ((average >= 80) && (average >= 87) && (perfectattendance==1)) { cout << "Your letter grade is an A" << endl; } else if ((average >= 80) && (average >= 87) && (perfectattendance==0)) { cout << "Yourletter grade is a B" << endl; } else if ((average >= 70) && (average < 77) && (perfectattendance==1)) { cout << "Your letter grade is a B" << endl; } else if ((average >= 70) && (average >= 77) && (perfectattendance==0)) { cout << "Your letter grade is a C" << endl; } else if ((average >= 60) && (average < 67) && (perfectattendance==1)) { cout << "Your letter grade is a C" << endl; } else if ((average >= 60) && (average < 67) && (perfectattendance==0)) { cout << "Your letter grade is a D" << endl; } else if ((average >= 50) && (average < 57) && (perfectattendance==1)) { cout << "Your letter grade is a D" << endl; } else if ((average >= 50) && (average < 57) && (perfectattendance==0)) { cout << "Your letter grade is an F and you failed the class" << endl; }``````

They should be..
 ``123456789101112131415161718192021222324252627282930313233343536`` ``````if (average >= 90) { cout << "Your letter grade is an A" << endl; } else if ((average >= 80) && (average <= 87) && (perfectattendance==1)) { cout << "Your letter grade is an A" << endl; } else if ((average >= 80) && (average <= 87) && (perfectattendance==0)) { cout << "Your letter grade is a B" << endl; } else if ((average >= 70) && (average < 77) && (perfectattendance==1)) { cout << "Your letter grade is a B" << endl; } else if ((average >= 70) && (average <= 77) && (perfectattendance==0)) { cout << "Your letter grade is a C" << endl; } else if ((average >= 60) && (average < 67) && (perfectattendance==1)) { cout << "Your letter grade is a C" << endl; } else if ((average >= 60) && (average < 67) && (perfectattendance==0)) { cout << "Your letter grade is a D" << endl; } else if ((average >= 50) && (average < 57) && (perfectattendance==1)) { cout << "Your letter grade is a D" << endl; } else if ((average >= 50) && (average < 57) && (perfectattendance==0)) { cout << "Your letter grade is an F and you failed the class" << endl; }``````

Just small, in-attention, mistakes.
when average equals 77 and perfectattendance is true you would expect this line to execute

`else if ((average >= 70) && (average < 77) && (perfectattendance==1))cout << "Your letter grade is a B" << endl;`

but it dosn't because `average < 77` does not evaluate to true should be `average <= 77`

or better yet cover the full range of grades `else if ((average >= 70) && (average < 80) && (perfectattendance==1))`

side note microsoft visual 2010 is out of date. You should upgrade to 2012.
Last edited on
thank you so much guys!!! definitely helped me out a lot
Just wanted to know if you wanted the program to evaluate perfect attendance? Because it is a bool that has been initialized with a 1 value it will always give perfect attendance for this program.
Topic archived. No new replies allowed.