Please.....Help with new program!

Program has No errors, but the program only prints on the screen " Please enter student's name" continuously and does not stop.

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
  // 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;
		cout << " Please enter the student's score " << endl;
		cin >> score;
		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;.
Last edited on
closed account (SECMoG1T)
End main with } put statements following the while
Loop into a block
while () { //statements}
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
//case 1
while(condition)
      cout<<"do 1";
      cout<<"do 2

//case 2
while(condition)
{
     cout<<"do 1";
     cout<<""do 2
     cout<<"do 3"
    etc.
} 

case 1

do 1 
do 1 
do1

case 2

do 1
do 2
do 3
do 1
do 2
do 3


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
Is this close to what you are asking for?


// 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;

}
Will this work?

// 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;

}
Topic archived. No new replies allowed.