Question
Why is this not giving me a letter grade when run? #include #include using namespace std; int main() { double grade1, grade2, grade3, grade4, total;
Why is this not giving me a letter grade when run?
#include
using namespace std;
int main() { double grade1, grade2, grade3, grade4, total;
cout << "please enter the first grade : "; cin >> grade1; cout << "Please enter the second grade : "; cin >> grade2; cout << "Please enter the third grade : "; cin >> grade3; cout << "Please enter the fourth grade : "; cin >> grade4;
total = (grade1 + grade2 + grade3 + grade4) / 4;
cout << "The average grade is : " << setprecision(6) << total << endl;
const int A_score = 90, B_score = 80, C_score = 70, D_score = 60;
int testScore;
cin >> testScore;
if (testScore >= A_score) cout << "Your grade is A. "; else if (testScore >= B_score) cout << "Your grade is B. "; else if (testScore >= C_score) cout << "Your grade is C. "; else if (testScore >= D_score) cout << "Your grade is D. "; else if (testScore >= 0) cout << "Your grade is F. "; else cout << "invalid test score. ";
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started