Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Skeleton Code: // cap.c // Read a student's results and compute his CAP. // This is a skeleton program for students. #include #include #define MAX_MODULES
Skeleton Code:
// cap.c // Read a student's results and compute his CAP. // This is a skeleton program for students. #include#include #define MAX_MODULES 50 void print_results(student_t, int); float compute_cap(student_t, int); int main(void) { student_t student; int num_modules, i; printf("Enter student's name: "); printf("Enter number of modules taken: "); printf("Enter results of %d modules: ", num_modules); // print_results(student, num_modules); // for checking printf("CAP = %.2f ", compute_cap(student, num_modules)); return 0; } // Print results of the student void print_results(student_t student, int num_modules) { int i; printf("Student's name: %s ", student.name); for (i=0; i Test Data: http://www.comp.nus.edu.sg/~cs1010/practice/2017s1/Practice-S11P04/testdata/
Task statement: Write a program cap.c that makes use of these structures: " result t that contains 3 members: a 7-character module code, the grade obtained by the student, and the number of modular credits (MCs) of that module; and " student t that contains the student's name (at most 30 characters), and an array of result t structures. You may assume that a student can take at most 50 modules. Your program should read in a student's name, the number of modules he has taken, and for each module, the module code, the grade obtained, and the number of modular credits. All these data should be stored in a student t variable. Your program should then compute the student's CAP (Cumulative Aggregate Point), based on this formula: CAP- (MCs Grade Point) / (MCs) The table below shows the grade point corresponding to each grade: Grade A+ or A A Grade Point B- 5.0 4.5 4.0 3.5 3.0 2.5 2.0 1.5 1.0 0 For example, if Brusco Beh has taken 5 modules and his results (module code, grade obtained, and number of MCs) are as follows: CS101O A+ 4 CS1231 B 4 MA1101R B+ 4 GEM1211 A- 3 PH2001 C 4 then his CAP is calculated as follows: (5.0x4 + 3.5x4 + 4.0x4 + 4.5x3 + 2.0x4) / (4 + 4 + 4 + 3 + 4) = 71.5/19 = 3.76
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started