Page 1 of 1

We need to write a program in Racket to calculate and return the GPA of a student. The data in the file is as follows, i

Posted: Sun Jul 03, 2022 11:21 am
by answerhappygod
We need to write a program in Racket to calculate and return theGPA of a student.
The data in the file is as follows, it is a list of lists,therefore, it is a 2D list:
(define record '(("Course" "Credits" "Grade") ("CMSC 299" 2"P")
("CMSC 331" 3 87)("CMSC 341" 3 100)("CHEM 201" 4 "Incomplete") ("PHYS 201" 4 77)("CMSC 491" "error" 100)))
The program reads the record and calculates the GPA using thefollowing formula:
GPA =  (course grade * course credit)/  (credit)
You need to implement the following functions:
Function call Description
(gpa record)
This is the main function which is called in the program andreturns the gpa. The function call exists in the file hw4.rkt andrunning your file must return the calculated gpa.
The output of function must be formatted as a floating-pointnumber with exactly 2 decimal points positions.The output of the function is a returned value. You are not allowedto use predefined functions like display or print to send output tothe screen.
This function calls the other functions to perform thecalculation.
(sum-of-grades record)
This function recursively traverses the record list andcalculates the summation of every grade by its correspondingcredits.The entry in the list that does not provide a grade field or acredit field as a number must be ignored. Such an entry is not usedin calculations.
You are not allowed to use predefined function list-ref toaccess members of a list. Instead, you must use car and cdr.
(sum-of-credits record)
This function recursively traverses the record list andcalculates the summation of all credits.The entry in the list that does not provide a grade field or acredit field as a number must be ignored. Such an entry is not usedin calculations.
You are not allowed to use predefined function list-ref toaccess members of a list. Instead, you must use car and cdr.
#lang racket(require racket/trace)(define record '(("Course" "Credits" "Grade") ("CMSC 299" 2 "P") ("CMSC 331" 3 87) ("CMSC 341" 3 100) ("CHEM 201" 4 "Incomplete") ("PHYS 201" 4 77) ("CMSC 491" "error" 100)))
#|Implement your functions here|#