This problem tests your ability to work with multiple arrays and multidimensional arrays.
Part 1: Creating a Grade-book
Represent a grade-book as two arrays. The first array should be a one-dimensional array of strings for storing the full names of students. The second array should be a two-dimensional array for storing the grades of the students whose names are in the first array. The sizes of these arrays should be specified using the predetermined constants NUM_STUDENTS and NUM_GRADES (provided for you below and both set to 5). A student's name and list of grades should share the same index in their respective arrays. In other words the grades for the student whose name is stored at location N in the name array should be stored in row N of the grade array (i.e. if John Doe's name is at position 3 in the name array his grades should be stored at row 3 in the grade array).
Populate the grade-book arrays with user input. For each student first prompt the user for the full name with the following text:
Please enter a student's full name on a single line then press "Enter":
After reading in the name, prompt the user to enter the student's grades with the following text:
Please enter the student's grades separated by white space:
After reading in the name and grades for a student, print them back to the screen on the same line before moving on to the next student. For instance, if the user were to input John Doe as a name, and the grades 98, 56, 87, 89, 27, the program should then print the line:
John Doe: 98 56 87 89 27
… before proceeding to process the next student's information.
Part 2: Printing the Grade-book
For this part of the problem you need to list all of the information in the grade-book plus their average grade. Do this by printing the name of each student on its own line, followed by a list of all of that student's grades on a single line that ends with the average of all of the student's grades. Repeat this process for each student/row in the grade-book. Here is sample input and output for a working solution:
Sample Input
Student A
100 100 100 100 100
Student B
100 100 100 100 100
John Doe
100 100 100 100 100
Jane Doe
100 100 100 100 100
Student C
0 0 0 0 0
this is what i have
#include
using namespace std;
const int NUM_STUDENTS=5;
const int NUM_GRADES=5;
int main(){
char Names[NUM_STUDENTS][30];
//It is not a 2-d array as names are group of characters therefore i have to use
//to define each name as an array therefore i have taken the maximum name length to
//30 characters NUM_STUDENTS indicate the number of students name in the array
//which makes us to resemble it like a 1-d
//2nd parameter is never changed therefore behaves like a 1-d array
int grades[NUM_STUDENTS][NUM_GRADES];
// it is 2 dimiensional array of each row representing each student grades in respectively
for(int i=0; i < 5;i++){
cout<<"Please enter a student's full name on a single line then press \"Enter\" : ";
cin >> (Names[i]);
}
for(int i=0;i<5;i++){
cout<<"Please enter a student's grades sperated by white space\n "<< Names[i] <<":";
for(int j=0;j<5;j++){
cin>>grades[i][j];
}
}
for(int i=0;i<5;i++){
cout< int avg=0;
for(int j=0;j<5;j++){
avg=avg+grades[i][j];
cout< }
cout << "Average score: "< }
}
this is what is happening