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()
{
float grade1= 77, grade2=77, grade3= 77, average;
int numgrades= 3;
bool perfectattendance;
perfectattendance= 1;
average = (grade1 + grade2 + grade3) /numgrades;
cout << "Grade1=77" << endl;
cout << "Grade2=77" << endl;
cout << "Grade3=77" << endl;
cout << "Your grade is:" << average << endl;
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;
}
cin.ignore(); // needed for Visual C++ Express 2010
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.
1 2 3 4
elseif ((average >= 70) && (average >= 77) && (perfectattendance==0))
{
cout << "Your letter grade is a C" << endl;
}
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.