8.7
Lecture 4: The design recipe
This assignment is due on Tuesday, January 17 at 11:59pm. Submit it using Handin as assignment lecture4. Your submission is only accepted if the message “Handin successful” appears.
1 Designing a function with 1 input

Exercise 1.
Design a function named ctok that converts a temperature in Celsius to a temperature in Kelvin.
Start by copying the following list of steps into your Definitions Window:
; Exercise 1 ; 1. Data definitions ; 2. Signature, purpose, header ; 3. Function examples ; 4. Function template ; 5. Function definition ; 6. Testing
Submit your work using Handin as assignment lecture4. Be sure to submit on time. Submit early and submit often, any number of times until the deadline!
Important Note Whenever you write a function in this class, you need to follow the design recipe.
The code written in the videos above is
available for your reference.
To download it, don’t use “Save Page As” or “Save As”;
use “Save Link As” or “Download Linked File” in your Web browser.
If you can’t find the command, try right-clicking or two-finger-tapping or
long-pressing.
Exercise 2. Turn all your function examples from comments into automatic tests.
Keep submitting your work any number of times until the deadline. Be sure to submit on time. Watch out for submitting to the wrong assignment.
Optional: Learn more about automatic testing.
2 Designing a function with 2 inputs
Exercise 3.
Design a function named coins that takes as inputs how many nickels
and how many dimes I have and calculates how many dollars I have in those coins.
Hint: If you need to review how to write a template, you can watch this
additional video.
The code written in the videos above is
available for your reference.
To download it, don’t use “Save Page As” or “Save As”;
use “Save Link As” or “Download Linked File” in your Web browser.
If you can’t find the command, try right-clicking or two-finger-tapping or
long-pressing.
3 Designing an animation
The code written in the video above is
available for your reference.
To download it, don’t use “Save Page As” or “Save As”;
use “Save Link As” or “Download Linked File” in your Web browser.
If you can’t find the command, try right-clicking or two-finger-tapping or
long-pressing.
Optional: Read Chapter 3 of the textbook.