hey guys im doing a program that requires me to:
'The program should keep a list of test scores for a group of students. It should ask the
user how many test scores there are to be and how many students there are. It should
then dynamically allocate an array of structures. Each structure’s Tests member
should point to a dynamically allocated array that will hold the test scores.
After the arrays have been dynamically allocated, the program should ask for the ID
number and all the test scores for each student. The average test score should be calculated
and stored in the average member of each structure. The course grade should
be computed on the basis of the following grading scale:
The course grade should then be stored in the Grade member of each structure. Once
all this data is calculated, a table should be displayed on the screen listing each student’s
name, ID number, average test score, and course grade.
Input Validation: Be sure all the data for each student is entered. Do not accept negative
numbers for any test score.'
i get all the answers im supposed to get but my average looks really messed up.. here is my code so far.. please help guys!i need it done by tomorrow... thanks in advance!
#include <iostream>
using namespace std;
const int columns = 4;
struct StuRec
{
int id[6];
char names[6][20];
int scores[6][4];
double avg[6];
char grade[6];
};
void avg(StuRec&);
char grade(StuRec&);
int main()
{
const int rows = 6;
//declare and allocate
StuRec r;
//enter student id
for(int i=0; i<6 ;i++)
{
cout<<"Enter Student id "<<i+1<<": ";
cin>>r.id[i];
}
cout<<endl;
//enter student+scores
for(int i=0; i<6 ;i++)
{
cout<<"Enter Name of student "<<i+1<<": ";
cin>>r.names[i];
cout<<endl;
}
for(int i=0; i<rows; i++)
{
cout<<"Enter "<<columns<<" scores for student "<<i+1<<": ";
for (int j=0; j<columns; j++)
{
cin>>r.scores[i][j];
}
cout<<endl;
}