Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Chapter 11, Programming Challenge 12: Course Grade Write a program that uses a structure to store structure data as describe in See instruction: Chapter 11

image text in transcribed

Chapter 11, Programming Challenge 12: Course Grade

Write a program that uses a structure to store structure data as describe in

See instruction: Chapter 11 Programming Challenge 12 Course Grade.pdfimage text in transcribedimage text in transcribed

Program template:

#include #include #include #include using namespace std;

// Declaration of Student structure struct Student { // TODO: structure for // 1) Student name, // 2) Student ID number, // 3) Pointer to array of test scores // 4) Average test score // 5) Course grade };

// Function prototypes Student *initArrays(int, int); void getInfo(Student[], int, int); void showInfo(Student[], int, int);

int main() { int numStudents; // Number of students int numTests; // Number of tests Student *list = nullptr; // Pointer to Student array

// Get the number of students. cout > numStudents;

// Get the number of tests per student. cout > numTests;

// TODO: Create an array of Students list = initArrays(numStudents, numTests);

// TODO: Populate the array with data. getInfo(list, numStudents, numTests);

// TODO: Display the data. showInfo(list, numStudents, numTests);

return 0; }

//************************************************** // Function initArrays * // This function dynamically allocates an array * // of Student structures and for each element in * // the array, allocates an array of ints to hold * // tests scors. The parameter s is the number of * // element to allocate for the array of structures * // and the parameter t is the number of elements * // allocate for each array of ints. * //************************************************** Student *initArrays(int s, int t) { Student *ptr = nullptr;

// Allocate the array of Student structures. ptr = new Student[s];

// TODO: Allocate an array of ints (to hold test scores) // for each element of the array of Student structures.

// Return a pointer to the array of structures. return ptr; }

//***************************************************** // Function getInfo * // This function populates the Student array s with * // data entered by the user. The paramater ns is the * // number of students and nt is the number of tests. * //*****************************************************

void getInfo(Student s[], int ns, int nt) { int total;

//TODO: Get the data for each student. }

//***************************************************** // Function showInfo * // This function displays all of the data in the * // array s. The paramater ns is the number of * // students and nt is the number of tests. * //***************************************************** void showInfo(Student s[], int ns, int nt) { // TODO: Displays all of the data in the array s }

12. Course Grade Write a program that uses a structure to store the following data: Description Member Name Student name Name Student ID number Idnum Pointer to an array of test scores Tests Average test score Average Course grade Grade 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 cal- culated and stored in the average member of each structure. The course grade should be computed on the basis of the following grading scale: Course Grade Average Test Grade 91-100 81-90 71-80 61-70 60 or below 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions