2023 Review 2

The 2023 final exam.

The starter code has check-expects.

It is OK to use the Racket Help Desk, but not work written by you or anyone else.

I. Problems (45 min)

These problems center around a “Quiz” struct that holds information for a teacher’s class. The Quiz structure contains:

  • name: a string, the name of the student who took the quiz
  • num: an integer, the number of the quiz. Example: the quiz given on Monday is 1 and the quiz from Wednesday is 2.
  • score: a number, the raw score that the student earned
  • max: a number, the maximum possible score on the quiz

Use the following definition:

(define-struct quiz (name num score max))

Write the following functions:

  1. quiz-percentage: Quiz -> Integer.

    Give the percentage score on the quiz rounded to the nearest whole number.

  2. person-total: String(who) (Listof Quiz) -> Integer.

    Find the total number of points a person has earned on all of the quizzes they took.

  3. curve-quiz Number(n) (Listof Quiz) -> (Listof Quiz).

    Given a quiz number, find the highest score on that quiz and then scale (multiplying/dividing) all of the scores so that the highest score becomes 100.

II. Animation (45 min)

You are going to write a “screen distance measurer”. It is going to keep track of the total distance between clicks.

  • Upper left corner shows cumulative total distance between clicks.
  • The first click places “anchor” to start measuring distance.
  • After the first click, you draw a line to where the mouse is.
  • The second click adds the distance to the total and makes the line vanish (until you click again).

Make a plan before you start coding!!

The starter code creates the background shown.

A video showing the animation in action is available on YouTube and there is a Google Drive link for CPS, in case the video is blocked.

<div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
  <iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="allowfullscreen" loading="eager" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube.com/embed/https://youtu.be/7zH5nbJFb1w?autoplay=0&controls=1&end=0&loop=0&mute=0&start=0" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" title="YouTube video"
  ></iframe>
</div>
Last modified August 18, 2023: 2022-2023 End State (7352e87)