HW0

Implement a program in C++ that does the follolwing
1.Read as input average course score
2.Proves it to find the letter grade
3. Display the better grade

#include <iostream>
#include <cmath>

using namespace std;

int main()

{
int x1=40, x2=30, x3=55, x4=99;
float avg;

avg = (x1+x2+x3+x4) / 4.0;

cout << "The average is: " << average << endl;
cout << "The letter grade is: " << grade << endl;

system ("PAUSE");
return 0;

}

I dont think I did this correctly
you're right, you didn't
You never have any input try something like
1
2
3
4
float grades[4];
cout << "Enter the grades for your classes separated with a space\n";
for (int i = 0; i < 4; i++)
     cin >> grades[i];

You never calculate the letter grade, do something like
1
2
3
4
5
6
7
8
9
10
11
char grade;
if (avg >= 90)
     grade = 'A';
else if (avg >= 80)
     grade = 'B';
else if (avg >= 70)
     grade = 'C';
else if (avg >= 60)
     grade = 'D';
else
     grade = 'F';
Then output the grade.

Is that what you want?

P. S. Use the code tags.
Last edited on
Topic archived. No new replies allowed.