Hi guys.
I'm trying to make a program where if more values were added then initially declared in then I want to make it the case that the last value is ignored.
So I have my input coming in from a data file.
Within the first line of the input it will declare the points per assignment as well as the amount of assignments.
Like so:
The -1 represents a sentinel.
So in this case there are 8 assignments and the total possible points are 100.
So the next line would state the score a student received on the assignments.
Like so:
Student A:
Student A recived a %100.
But we might have a case like Student B:
Student scored 150/100. This cannot be allowed.
so I'm thinking I make a counter for the first line feed like so:
1 2 3 4 5 6
|
while (total_points != -1) // While the total points are not 1 then add up all the assignment points within the data set
{
sum = sum + total_points;
cin >> total_points;
assignment_count++;
}
|
and then something like this:
1 2 3 4 5 6 7 8
|
cin >> first_letter; // Read the first value from the new line
while (cin)
{
cin >> first_number >> second_number >> second_letter;
cin >> student_points;
student_sum = 0.0;
student_assignment++;
|
But then I'm a little confused.
Should I implement a if statement within the second while loop?
like
1 2
|
if (student_assignment > assignment_count)
then ignore the last value in student count, or whatever extra values there are.
|
How can I implement that if statement within my second while loop?