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

Recommended Answers

All 2 Replies

Member Avatar for v3ga

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.