I'm trying to increment students by 1, but each time it shows output it says "Student 1..." again and again.
#include <iostream>
using namespace std;
int main()
{
//variables
int i = 0;
int student = i;
int midterm = 0;
int final = 0;
int total = 0;
//Prompt the user to enter the number of students.
cout << "Enter the number of students: ";
cin >> student;
while (i != -1)
{
cout << "Enter student " << i + 1 << " midterm grade: ";
cin >> midterm;
cout << "Enter student " << i + 1 << " final grade: ";
cin >> final;
total = midterm + final;
if (total >= 360 && total <= 400)
{
cout << "Student " << i + 1 << " grade is A." << endl;
}
else if (total >= 320 && total <= 359)
{
cout << "Student " << i + 1 << " grade is B." << endl;
}
else if (total >= 280 && total <= 319)
{
cout << "Student " << i + 1 << " grade is C." << endl;
}
else if (total >= 240 && total <= 279)
{
cout << "Student " << i + 1 << " grade is D." << endl;
}
else if (total < 240)
{
cout << "Student " << i + 1 << " grade is F." << endl;
}
else
{
cout << "Total can not be more than 400 points." << endl;
break;
}
}
}
Last edited on
Yes, actually. I appreciate the help.