;; Student data base example (setf student1 '((Paul Bennett) ((hw1 4.3) (hw2 5.0) (hw3 3.5) (hw4 4.8) (hw5 4.9)) ((test1 9.5) (test2 8.7)) (classw 10.0) (project 18) (final 28))) (setf student2 '((Abe Cadman) w)) (setf student3 '((Nelson DaCunha) ((hw1 4.8) (hw2 4.0) (hw3 4.5) (hw4 3.8) (hw5 5.0)) ((test1 8.5) (test2 9.7)) (classw 10.0) (project 17) (final 25))) (setf student4 '((Susan Melville) ((hw1 3.8) (hw2 5.0) (hw3 4.7) (hw4 4.8) (hw5 5.0)) ((test1 8.3) (test2 9.9)) (classw 10.0) (project 20) (final 24))) (setf student5 '((Igor Pevac) w)) (setf student-list (list student1 student2 student3 student4 student5)) (defun homework-points (homeworks) (cond ((endp homeworks) 0) (t (+ (second (first homeworks)) (homework-points (rest homeworks)))))) (defun test-points (tests) (cond ((endp tests) 0) (t (+ (second (first tests)) (test-points (rest tests)))))) (defun total-points (student) (setf total-points (+ (homework-points (second student)) (test-points (third student)) (second (cadddr student)) (second (first (cddddr student))) (second (first (last student))))) (format t "~%Student: ~a ~a" (first (first student)) (second (first student))) (format t "~&Total points: ~a" total-points) (format t "~& - homework points: ~a" (homework-points (second student))) (format t "~& - test points: ~a" (test-points (third student))) (format t "~& - classwork points: ~a" (second (cadddr student))) (format t "~& - project points: ~a" (second (first (cddddr student)))) (format t "~& - final: ~a" (second (first (last student))))) (defun grades (student-list) (cond ((endp student-list) nil) ((not (eql (second (first student-list)) 'w)) (total-points (first student-list)) (grades (rest student-list))) (t (grades (rest student-list))))) (defun find-w (student-list) (cond ((endp student-list) nil) ((eql (second (first student-list)) 'w) (cons (first (first student-list)) (find-w (rest student-list)))) (t (find-w (rest student-list))))) (defun avarage (student-list assignment) (setf number-of-students 0) (case assignment (hw1 (/ (get-total-hw1 student-list) number-of-students)) (hw2 (/ (get-total-hw2 student-list) number-of-students)) (hw3 (/ (get-total-hw3 student-list) number-of-students)) (hw4 (/ (get-total-hw4 student-list) number-of-students)) (hw5 (/ (get-total-hw5 student-list) number-of-students)) (test1 (/ (get-total-test1 student-list) number-of-students)) (test2 (/ (get-total-test2 student-list) number-of-students)) (otherwise (format t "~%Enter hw1, hw2, hw3, hw4, hw5, test1 or test2")))) (defun get-total-test1 (student-list) (cond ((endp student-list) 0) ((not (eql (second (first student-list)) 'w)) (setf number-of-students (+ 1 number-of-students)) (+ (second (first (third (first student-list)))) (get-total-test1 (rest student-list)))) (t (get-total-test1 (rest student-list))))) (defun count-w (student-list) (cond ((endp student-list) 0) ((eql (second (first student-list)) 'w) (+ 1 (count-w (rest student-list)))) (t (count-w (rest student-list))))) (defun search-w (student-list) (cond ((endp student-list) nil) ((eql (second (first student-list)) 'w) (first (first student-list))) (t (search-w (rest student-list))))) (defun get-w (student) (eql (second student) 'w)) (defun get-project (student) (second (fifth student))) (defun search-project-20 (student-list) (cond ((endp student-list) nil) ((eql 20 (get-project (first student-list))) (first (first student-list))) (t (search-project-20 (rest student-list))))) ;; Here are some additional functions (not finished) ;; that may be helpful ;; (defun get-total-test2 (student-list) .......) ;; (defun get-total-hw1 (student-list) .......) ;; (defun get-total-hw2 (student-list) .......) ;; (defun get-total-hw3 (student-list) .......) ;; (defun get-total-hw4 (student-list) .......) ;; (defun get-total-hw5 (student-list) .......) ;; (defun get-total-hw6 (student-list) .......)