Question: (a) Declare suitable C datatypes to represent each of the following sets of information (as you would do in a header file): (i) A university

(a) Declare suitable C datatypes to represent each of the following sets of information (as you would do in a header file): (i) A university unit, including: a name (a string up to 50 characters), a unit ID (an integer) and a list of 4 marks (integers) that an individual student has attained. (Test1, Test2, Assignment and Exam) (ii) A student record, where each student has a name (up to 100 characters), a student ID (an integer), their course weighted average (real), and a list of zero or more unit details. (iii) A list of student records, able to hold the details of any number of students.
(iv) An customer record, where each customer has a name (up to 50 characters), a customer ID (an integer), their sales consultant ID, and a set of zero or more purchase details. (v) A set of customer records, able to hold the details of any number of customers (b) Write a C function called loadStudents to read a list of student records from a text file. The file can contain any number of records. Each line contains one record, consisting of a name, student ID, CWA, unit name, unit ID, and the students marks, in that order, separated by commas. The following is an example file: Donald Smith,123456,69.7,UCP,1000,66,54,87,52 Donald Smith,123456,69.7,OOPD,1001,67,58,78,83 John Brown,987654,88.3,OOPD,1001,58,85,91,88 George Foreman,765456,51.2,DSA,1002,76,89,100,95 Your function should: Import a filename. Read the file, according to the above specifications. Dynamically allocate the structures you designed in part (a). Store each record in these structures. Return a pointer to the list of records, or NULL if an error occurs. If the file can be opened, you may assume that it definitely conforms to the specification, and that there are no blank entries. (c) Write a C function called calcAveMarks, which determines the average mark for each assessment in a particular unit. Specifically, the function must: Import a pointer to the information returned by the loadStudents function. Import the ID for the unit in question. Return nothing. Cycle through the students, finding those who have completed the unit in question. Output the name of the unit, followed by the average of each assessment.
(d) Write a main function that accepts two command-line parameters: an input filename and a unit ID. Given these, main should: Conduct all appropriate error checking and handling. Use the function loadstudents from part (b) to read the input file. Use the function calcAveMarks from part (c) to calculate and display the average marks. Perform all necessary cleaning up.
For this question, refer to the following standard C function prototypes: FILE *fopen(const char *path, const char *mode }; int fclose (FILE *fp)i int fscanf (FILE *stream, const char format, . char fgets (char s, int size, FILE stream) int feof (FILE stream) int strcmp (const char s1, const char s2) char strncpy (char *dest, const char src, size t n) int atoi (const char nptr); For this question, refer to the following standard C function prototypes: FILE *fopen(const char *path, const char *mode }; int fclose (FILE *fp)i int fscanf (FILE *stream, const char format, . char fgets (char s, int size, FILE stream) int feof (FILE stream) int strcmp (const char s1, const char s2) char strncpy (char *dest, const char src, size t n) int atoi (const char nptr)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
