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.
#include <iostream>
#include <fstream>
usingnamespace std;
int main()
{
char MoreStudent;
char grade;
int StudentID;
int SIZE = 0;
constint 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';
}
elseif (average >= 50)
{
grade = 'S';
}
else
{
grade = 'U';
}
average /= SIZE;
cout << "ID: " << StudentID << " Avg= " << average << " Grade= " << grade << endl;
system("pause");
return 0;
}