without the opening and closing braces, only the first line after the while is executed as part of the while.
In your program, only line 20 is part of the while and always true for the condition.
Group the statements you want to be part of the while with open and closing curly braces
// The program will read ten names form the user's input and compute //
// the grade for each name and prints the grade and tell whether the //
// grade is excellent, well done, good, or needs improvement. //
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
char studentname;
int score;
int totalpoints;
float finalscore;
int percentage;
int count;
count = 1;
while (count < 10)
{
cout << "Please enter the student's name " << endl;
cin >> studentname;
}
while (count < 10)
{
cout << " Please enter the student's score " << endl;
cin >> score;
}
while (count < 10)
{
cout << " Please enter the total points " << endl;
cin >> totalpoints;
}
finalscore = score / totalpoints;
percentage = finalscore * 100;
if (percentage >= '90')
cout << studentname << percentage << "%" << finalscore << "Excellent" << endl;
if (percentage >= '80' && percentage < '90')
cout << studentname << percentage << "%" << finalscore << "Well Done" << endl;
if (percentage >= '70' && percentage < '80')
cout << studentname << percentage << "%" << finalscore << "Good" << endl;
if (percentage >= '60' && percentage < '70')
cout << studentname << percentage << "%" << finalscore << "Needs Improvement" << endl;
count = count++;
return 0;
// Programmer: David Weeks //
// Course Name: CIS 301 - Intro to Business Application Programming //
// Lab Number: Lab 6 //
// The program will read ten names form the user's input and compute //
// the grade for each name and prints the grade and tell whether the //
// grade is excellent, well done, good, or needs improvement. //
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
char studentname;
int score;
int totalpoints;
int percentage;
int count;
float finalscore;
count = 1;
while (count <= 10)
{
cout << "Please enter the student's name " << endl;
cin >> studentname;
cout << "Please enter the student's score " << endl;
cin >> score;
cout << "Please enter the total points " << endl;
cin >> totalpoints;
count = count++
}
finalscore = score / totalpoints;
percentage = finalscore * 100;
if (percentage >= '90')
cout << studentname << percentage << "%" << finalscore << "Excellent" << endl;
if (percentage >= '80' && percentage < '90')
cout << studentname << percentage << "%" << finalscore << "Well Done" << endl;
if (percentage >= '70' && percentage < '80')
cout << studentname << percentage << "%" << finalscore << "Good" << endl;
if (percentage >= '60' && percentage < '70')
cout << studentname << percentage << "%" << finalscore << "Needs Improvement" << endl;
if (percentage < '50' && percentage < '60')
cout << studentname << percentage << "%" << finalscore << "Failed" << endl;
return 0;