Answer to Question #283049 in C++ for Jonas

Question #283049


The program below computes the grade of five students based on the marks scored. Study it carefully, identify the different errors the program has, correct the errors and hence re-write the program so that it can run successfully without errors.



1
Expert's answer
2021-12-27T15:51:01-0500
#include<iostream>
#include<string>

using namespace std;

int main()
{
	string names[5];
	double grades[5];
	int i = 0;
	do
	{
		cout << "Please, enter a name of student " << i + 1 << " :";
		cin >> names[i];
		double sumgrd = 0;
		int j=0;
		cout << "Please, enter grades of student "<<i+1<<" (-1 - for stop) :";
		double grade;
		do
		{
			cin >> grade;//Read grades to -1
			if (grade == -1)break;
			sumgrd += grade;
			j++;
		} while (grade > 0);
		sumgrd /= j;
		grades[i] = sumgrd;
		i++;
	} while (i < 5);
	for (int j = 0; j < 5; j++)
	{
		cout << "\nStudent`s name: \t" << names[j]
			<< "\nStdent`s average grade:\t" << grades[j];
	}
	
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog