|
||||||||||
copyright © 2006 Don Southwell - All rights reserved |
|
||||||||||
copyright © 2006 Don Southwell - All rights reserved |
Structured Data and Abstract Data Types Lab Your Mission: Write a program that uses a structure to store the following data:
The program should keep a list of test scores for a group of students. It should ask the user how man tests scores there are to be and how many students there are. It should then dynamically allocate an array of structures to hold the student records. Each structure's Tests member should point to a dynamically allocated array which 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, based on the following grading scale:
The course grade should them 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 dat for each student is entered. Do not accept negative numbers for any test score. Algorithmic suggestion: You can use this if you wish or go it alone. // Name: #include <iostream> // Constants for arrays // Declaration of Student structure char name[NAME_SIZE]; // Student name }; // Function prototypes int main() // Get the number of students. //************************************************** Student *initArrays(int s, int t) // Allocate the array of Student structures. // Allocate an array of ints (to hold test scores) // Return a pointer to the array of structures. //***************************************************** void getInfo(Student s[], int ns, int nt) // Get the data for each student. // Get the test scores and accumulate a total. // Calculate the average score. // Assign a letter grade. //***************************************************** void showInfo(Student s[], int ns, int nt) //Define variables as needed. //Use a for loop to step through the record structure and display
the student information |
! You are using a version 4 browser or older. If you are experiencing any problems with scrolling, please reload the page.