Five Grades of a Student

so my professor wanted us to create a program that accepts five grades of a student, then compute it's average and determine whether the average is passing or a failing grade

here's his sample out:

P.S. I'm still new to c++ so I'm kind of mentally blocked at the moment lol

Input 1st Grade: 89
Input 2nd Grade: 90
Input 3rd Grade: 93
Input 4th Grade: 88
Input 5th Grade: 87


AVERAGE: 89.4
it is a PASSING GRADE


so far this is what I have I'm still missing the determine whether it's a passing or failing thing ._.



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
	double grade1, grade2, grade3, grade4, grade5;
	cout <<"Input 1st Grade: ";
	cin  >>grade1;
	while (grade1 < 0)
	{
	cout <<"grades cannot be negative. Please input the 1st grade: ";
		cin  >>grade1;
	}
        cout <<"Input 2nd Grade: ";
        cin  >>grade2;
        while (grade2 < 0)
        {
    	cout <<"grades cannot be negative. Please input the 2nd grade: ";
        cin  >>grade2;
	}
        cout <<"Input 3rd Grade: ";
        cin  >>grade3;
        while (grade3 < 0)
        {
    	cout <<"grades cannot be negative. Please input the 3rd grade: ";
        cin  >>grade3;
	}
	cout <<"Input 4th Grade: ";
        cin  >>grade4;
        while (grade4 < 0)
        {
        cout <<"grades cannot be negative. Please input the 4th grade: ";
	cin  >>grade4;
	}
	cout <<"Input 5th Grade: ";
        cin  >>grade5;
        while (grade5 < 0)
	{
    	cout <<"grades cannot be negative. Please input the 5th grade: ";
		cin  >>grade5;
	}
	
	
	cout <<"AVERAGE: " << setprecision(2) << fixed << showpoint << (grade1  + grade2 + grade3 + grade4 +grade5) / 500 * 100 << "\n";
	system("pause");
	return 0;
}
Last edited on
Hi and welcome, please edit your post and put all of your code in code tags - http://www.cplusplus.com/articles/jEywvCM9/

You forgot to ask a question regarding this problem. What exactly do you want from us?
ahh anyways I'm kinda bit having hard time figuring out the determine whether it's a passing grade or a failing grade :/
Well. It depends, how much points does the user have to get to get a passing grade? If its 50, just check that the average is over 50, if it is, tell them they passed. You can do this using if-statements.
Topic archived. No new replies allowed.