7.3  Example: Keeping Track of Grades

Data definitions:

;; A gradebook (gb) is: (Listof GBE).

(define-struct gbe (name grades))
;; A GBE (grade-book entry) is: 
;;          (make-gbe symbol (Listof Number))

;; Example:
(define gradebook
  (list (make-gbe 'ALICE (list 49 81 64))
        (make-gbe 'BOB   (list 16 31 27))
        (make-gbe 'CARL  (list 27 64 8))))


Exercise

Exercise 7.1.   Design

;; students-in : GB  →  (Listof Symbol)

which enumerates the students in the course (duplicates are okay). 

Exercise 7.2.   Design

;; grades-of : GB Symbol  →  (Listof Number)

which extracts the grades for a given student from the given GB

Exercise 7.3.   Design

;; total-of : GB Symbol  →  Number

computes the total score for a given student from the given GB

Exercise 7.4.   Design

;; highest-total : GB  →  Number

which determines who has the highest total score in the class. 

Exercise 7.5.   Design

;; chart-grades : GB  →  Histogram

which consumes a gradebook and generates a histogram.

;; A Histogram is: (Listof HistoLine).

(define-struct histoline (name result))
;; A HistoLine is:  (make-histoline Symbol String)
;; Note: the result string is at most 60 characters long. 

Each item of the generated list is a name combined with a string representing the histogram entry. The longest string, representing the person with the highest grade, should be 60 characters long. Every other string should be proportionally shorter. You may need some math functions to help you compute the lengths of strings; once you’ve determined what functions you need, ask the TAs for help finding these in Scheme or experiment or use the HelpDesk.