Aug 28, 2020 at 12:27am UTC
When I try to run my code, after 2 tries, the average does not compute.
I have to compile again for it to work again even though there was no change to the code.
Here is my code:
#include <iostream>
using namespace std;
int main()
{
bool topic = true;
string course, EE306, EE312, EE330, CSC210;
float Average, Homework, Midterm1, Midterm2, Final, Project1, Project2;
while (topic == true)
{
cout << "Enter the course: ";
cin >> course;
cout << endl;
if (course == "EE306" || course == "EE312" || course == "EE330")
{
cout << "Homework: ";
cin >> Homework;
cout << "Midterm 1: ";
cin >> Midterm1;
cout << "Midterm 2: ";
cin >> Midterm2;
cout << "Final: ";
cin >> Final;
}
else if (course == "CSC210")
{
cout << "Project 1: ";
cin >> Project1;
cout << "Project 2: ";
cin >> Project2;
}
else
{
cout << "Invalid Entry. Please try again.";
}
cout << endl;
if (course == "EE306")
{
Average = Homework*0.1 + Midterm1*.25 + Midterm2*.25 + Final*.4;
}
else if (course == "EE312")
{
Average = Homework*0.15 + Midterm1*.25 + Midterm2*.25 + Final*.35;
}
else if (course == "EE330")
{
Average = Homework*0.15 + Midterm1*.25 + Midterm2*.25 + Final*.35;
}
else if (course == "CSC210")
{
Average = Project1*.49 + Project2*.51;
}
if (Average < 60)
{
cout << "Your Average is " << Average << endl << "Your grade is F." << endl << "=== SORRY YOU FAILED ! ===" << endl;
}
else if ((Average >= 60) && (Average < 70))
{
cout << "Your Average is " << Average << endl << "Your grade is D." << endl << "=== YOU PASSED. ===" << endl;
}
else if ((Average >= 70) && (Average <= 72))
{
cout << "Your Average is " << Average << endl << "Your grade is C- ." << endl << "=== YOU PASSED. ===" << endl;
}
else if ((Average > 72) && (Average <= 76))
{
cout << "Your Average is " << Average << endl << "Your grade is C." << endl << "=== YOU PASSED. ===" << endl;
}
else if ((Average > 76) && (Average <= 79))
{
cout << "Your Average is " << Average << endl << "Your grade is C+ ." << endl << "=== YOU PASSED. ===" << endl;
}
else if ((Average >= 80) && (Average < 82))
{
cout << "Your Average is " << Average << endl << "Your grade is B- ." << endl << "=== GOOD WORK ! ===" << endl;
}
else if ((Average > 82) && (Average <= 86))
{
cout << "Your Average is " << Average << endl << "Your grade is B." << endl << "=== GOOD WORK ! ===" << endl;
}
else if ((Average > 86) && (Average <= 89))
{
cout << "Your Average is " << Average << endl << "Your grade is B+ ." << endl << "=== GOOD WORK ! ===" << endl;
}
else if ((Average >= 90) && (Average < 92))
{
cout << "Your Average is " << Average << endl << "Your grade is A- ." << endl << " === CONGRATULATIONS !! ===" << endl;
}
else if ((Average > 92) && (Average <= 96))
{
cout << "Your Average is " << Average << endl << "Your grade is A." << endl << " === CONGRATULATIONS !! ===" << endl;
}
else if ((Average > 96) && (Average <= 100))
{
cout << "Your Average is " << Average << endl << "Your grade is A+ ." << endl << " === CONGRATULATIONS !! ===" << endl;
}
cout << endl;
}
return 0;
}
and here it is when i run it:
Enter the course: EE306
Homework: 100
Midterm 1: 89
Midterm 2: 85
Final: 92
Your Average is 90.3
Your grade is A- .
=== CONGRATULATIONS !! ===
Enter the course: EE312
Homework: 100
Midterm 1: 96
Midterm 2: 81
Final: 89
Your Average is 90.4
Your grade is A- .
=== CONGRATULATIONS !! ===
Enter the course: EE330
Homework: 98
Midterm 1: 98
Midterm 2: 75
Final: 89
Enter the course: