I have to write a program that should read test scores students received on the first quiz into an array. Assume that up to 30 students could be entered. Input will stop when the sentinel value -1 is entered.

Write functions to:

1. Read the original scores into arrays

2. Compute the distribution of scores accordeing to the following scheme, i.e. count number of As, Bs, etc.

A:90-100
B:80-89 and so on

3. Find how many students have the same score.

4. Display number of students, the distribution of scores, and number of students with the same score.

This is what I have so far; everything works except totaling the students. I am trying to do this step by step. I have the read test scores, but now I am trying to total the number of students, then compute the distribution.

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

using namespace std;

void readinfo(int);
int totalstudents (int);
void displayinfo;

int main()
{
	const int VALS_LEN = 30;
	
	int totalstudents[VALS_LEN];
	
	cout << "Welcome to the student test manager!" << endl;
         readinfo(VALS_LEN);
	
        cout << endl;
	cout << "Report " << endl;
	cout << "______ " << endl;
	cout << endl;
	cout << "Number of students: " << totalstudents << endl;




system ("pause");
return 0;
}

void readinfo(int testscores)
{
      for( int studentScores = 0; studentScores < testscores; studentScores ++)
	{
	while(testscores != -1)
		{
		 cout << "Please enter student test scores (or -1 to quit): ";
		 cin >> testscores;
			
		}
	}
}

int totalstudents (int students)
{
	int testscores;
	int total = 0;

	for (int students = 0; students < 30; students ++)
	{
	 total = testscores ++;
	 return total;
		
	}
}

void displayinfo

Edited 4 Years Ago by WaltP: Added CODE Tags -- please use them

Not one question was asked. Not one problem was explained. All that you said was "now I am trying to total the number of students, then compute the distribution". So do it.

If you're having a problem, you need to explain what it is.

Sorry, I thought I did. I am having problems trying to get the function void totalstudents to calculate the number of students that grades are marked for. So my first part that requests the user to input the scors of the students for the quiz works. I can input the different grades. My problem is I can't figure out how to calculate the total number of students (which is based on the total number of scores entered) up to 30. I have to do this with a pointer and/or array.

That is what I displayed. My program thus far, but the function definition totalstudents is not working.

Not one question was asked. Not one problem was explained. All that you said was "now I am trying to total the number of students, then compute the distribution". So do it.

If you're having a problem, you need to explain what it is.

I have to write a program that should read test scores students received on the first quiz into an array. Assume that up to 30 students could be entered. Input will stop when the sentinel value -1 is entered.

Write functions to:

1. Read the original scores into arrays

2. Compute the distribution of scores accordeing to the following scheme, i.e. count number of As, Bs, etc.

A:90-100
B:80-89 and so on

3. Find how many students have the same score.

4. Display number of students, the distribution of scores, and number of students with the same score.

This is what I have so far; everything works except totaling the students. I am trying to do this step by step. I have the read test scores, but now I am trying to total the number of students, then compute the distribution.

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

using namespace std;

void readinfo(int);
int totalstudents (int);
void displayinfo;

int main()
{
	const int VALS_LEN = 30;
	
	int totalstudents[VALS_LEN];
	
	cout << "Welcome to the student test manager!" << endl;
         readinfo(VALS_LEN);
	
        cout << endl;
	cout << "Report " << endl;
	cout << "______ " << endl;
	cout << endl;
	cout << "Number of students: " << totalstudents << endl;




system ("pause");
return 0;
}

void readinfo(int testscores)
{
      for( int studentScores = 0; studentScores < testscores; studentScores ++)
	{
	while(testscores != -1)
		{
		 cout << "Please enter student test scores (or -1 to quit): ";
		 cin >> testscores;
			
		}
	}
}

int totalstudents (int students)
{
	int testscores;
	int total = 0;

	for (int students = 0; students < 30; students ++)
	{
	 total = testscores ++;
	 return total;
		
	}
}

void displayinfo

Hi,

The function readinfo is getting the user info but not saving it, you should save the infos into an array, and later you can read the infos from the array and do some calculation. so pass the readinfo a second param , a pointer, in which data should be used.

some thing like this

void readinfo(int testscores, int* arrayOfScores)
{
        int inData;
        int studentScores  = 0 ;
	while( true )
		{
		 cout << "Please enter student test scores (or -1 to quit): ";
		 cin >> inData;
                 if(inData == -1 || studentScores >= testscores)
                     break;
                  arrayOfScores[ studentScores++] = inData;
		}
	
}
This article has been dead for over six months. Start a new discussion instead.