Question: C++ Design, develop, and test a program that uses a structure Student to store the data indicated below. The program keeps a list of test
C++ Design, develop, and test a program that uses a structure Student to store the data indicated below. The program keeps a list of test scores for a group of students, prompting the user for number of test scores and number of students; it then dynamically allocates an array of Student structs, and each Students tests member points to a dynamically allocated array of test scores. After the arrays are dynamically allocated the program prompts for the name, id number, and all the test scores for each Student; it then computes the average test score and stores it in the avg member of each struct. [Data validation: ensure that no test score entered is less than 0 or greater than 100.] The program determines the grade member value based on this scale: 0..64.9 => F 65..70.9 => D 71..80.9 => C 81..90.9 => B 91..100 => A; it then stores the grade in the grade member of the struct. The program then prints a table listing name, ID number, average test score, and course grade. The struct, function prototypes, and partial sample output are given here:
*The full question does not have to be answered but rather I would like some insight or at the very least the function Student * initArys(int s, int t); be completed. I'm not very good with pointers and everything that has pointers I just fall apart.
struct Student {
string name; // Student name
int idNo; // Student ID number
int * tests; // pointer to array of test scores
double avg; // average test score
char grade; // course grade
};
// initArys() dynamically allocates an array of Student structures and
// for each Student element an array of ints to hold test scores; s is
// number of elements to allocate for array of structures; t is number
// of elements to allocate for each array of ints
Student * initArys(int s, int t);
// getInfo() populates the Student array s with data entered by the user;
// ns is number of students and ne the number of tests
void getInfo(Student s[], int ns, int ne);
// prntInfo() displays all of the data in array s; ns is the number of
// students and ne the number of tests
void prntInfo(Student s[], int ns, int ne);
/* Sample output:
How many students? 6
How many tests per student? 3
Student name: Rose Ann Bosch
ID Number: 741892
Test #1: 67
Test #2: 88
Test #3: 78
Student name: Sami Smrti
. . .
Student name: Travis Jones
ID Number: 238152
Test #1: 56
Test #2: 76
Test #3: 74
Student Name ID Number Avg. Grade
--------------- --------- ---- -----
Rose Ann Bosch 741892 77.7 C
Sami Smrti 218753 92.7 A
Jonathan Lee 431827 54.7 F
Randi Randle 426071 85.3 B
Ned Nelsen 217387 88.0 B
Travis Jones 238152 68.7 D */
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
