using -1 for excused absence.

i'm having trouble with excused absences.this is how my professor wants it.

"When entering the scores, if a student had an excused absence for a score it will be entered as -1. If a student has 2 or more excused absences, then do not compute the average and give the student a grade of I. If the student has less than 2 excused absences then compute the average and determine the grade. Of course for a student with 1 excused absence the average should not count the –1 score. For example, if the input scores for a student were 53, -1, 49 and 50, your program would ignore the -1, since this is the student’s only absence. For this student average will be (53+49+50)/3. The grade of S should be assigned if the student's average is 50.0 or above and U if it is below 50.0."

I'm having a real tough time figuring out if a user puts in two -1 that the output will show that is excused instead giving me an average.


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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <iostream>
#include <fstream>
using namespace std;

int main()
{
	char MoreStudent;
	char grade;
	int StudentID;
	int SIZE = 0;
	const int MAX_SIZE = 15;
	int Scores[MAX_SIZE];
	int average = 0;
	int numExcuses = 0;

	cout << "Enter the ID and scores for each student. If a student has an excused absence, then enter -1 for that score" << endl;
	cout << "Enter the number of scores for this semester: ";
	cin >> SIZE;

	Scores[SIZE];


	cout << "Add a student (Y to continue, any other character to end): ";
		cin >> MoreStudent;
			if (MoreStudent == 'Y' || MoreStudent == 'y')
			{
				cout << "Enter Student's ID: ";
				cin >> StudentID;
				for (int count = 0; count < SIZE; count++)
					{
						cout << "Enter a score: ";
						cin >> Scores[count];
						average+= Scores[count];
					}
			}
			

			
			if (numExcuses >= 2)
			{
			    grade = 'I';
			}
			
			    else if (average >= 50)
			    {
			        grade = 'S';
			    }
			    else
			    {
			        grade = 'U';
			    }
			 
			average /= SIZE;

			cout << "ID: " << StudentID << " Avg= " << average << " Grade= " << grade << endl;






	system("pause");
	return 0;
}
Topic archived. No new replies allowed.