0

I'm trying to figure out how to do this program. A program is required to print and read a series of exam scores for students enrolled in a math class. The class average is to be computed and printed at the end of the report. Score can range form 0 - 100. The last record contains a blank name and score of 999 and is to not be included in the calculations.
-a do while structure to control the reading of exam scores until it reaches a score of 999
- an accumulator for total score
- an accumulator for total students

This is what I have so far:

#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

int main()
{
	string name;
	int score;
	int average;
	int total_score;
	int total_students;
	int temp_one;
	int temp_two;

	cout << "Please enter students name and test score 0 - 100 with a space in     between." << endl;
	
	
	temp_one = total_score;
	temp_two = total_students;
	total_score = 0;
	total_students = 0;

	do
	{
		cin >> name >> score;


	}
	
	while (score < 999);

	cout << name << score << endl;
	cout << "The class average is: " << average << endl;
		
}

Edited by WolfPack: Added [CODE[/CODE] tags

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by jmichae3
0

I would make a student structure and make an array of objects if the scores need to be stored.
Else if u only want the avg to be printed just accept scores(no names) sum=sum+score; count++ and after loop do sum/count.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.