CS1321 Fall AY2002 Homework 2 Due Tuesday, August 28, 2001 ___________________________________________________________________________ =x%=x%=x%=x%=x%=x%=x%=x%=x%=x%=x%=x%=x%=x%=x%=x%=x%=x%=x%=x%=x%=x%=x%=x%=x% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _____ |_ _| he following programming problems should be done using DrScheme. | | Be sure to save your function definitions by selecting "Save | | Definitions"/"Save Definitons as" from the "File" menu of DrScheme. |_| You will turn in this assignment during class on Tuesday, August 28, 2001, so bring a printout of your functions to class. (Actually make two printouts: one to keep during class, and one to turn in at the beginning of class.) Since you are handing in the program on paper, it does not matter what you call your electronic copy of the file. However, you might as well call it "hw2.scm". A similar naming convention will be introduced in future homeworks. This assignment must be completed using the design recipe technique demonstrated in the text, "How to Design Programs". In addition to the contract outline specified in p. 17, of the text we will add and name, gtnumber and class/assignment field. Thus: ;; John Doe ;; gt1234a ;; cs1321 homework ;; Contract: area-of-ring: number number --> number ;; Purpose : to etc. etc. etc. _ _ | \ | | ote that this addition appears once at the top of the file, so that | \| | we may identify your work. You do not need to place this at the | |\ | top of every function. Please place all of your functions in the |_| \_| same file. The major emphasis of this assignment is the design recipe technique outlined in the text. If you are not comfortable with this approach, please review the chapter before starting. ___________________________________________________________________________ =x%=x%=x%=x%=x%=x%=x%=x%=x%=x%=x%=x%=x%=x%=x%=x%=x%=x%=x%=x%=x%=x%=x%=x%=x% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. Define a function called Celsius->Fahrenheit, a function that takes a temperature in Celsius as a paramter and produces the equivalent temperature in Fahrenheit. You might remember that the formula to convert a Fahrenheit temperature to it's Celsius equivalent is C = (5/9) (F - 32). Hint: Be sure to solve for F, and not C; look carefully at the purpose of the function. Useful References: "How To Design Programs", p. 10 Online: http://www.htdp.org/2001-01-18/Book/node18.htm The references listed above show you how to combine a similar function with a supplied gui and interaction system. Note, however, that the version used in the book works with a Fahrenheit->Celsius conversion. 2. For the past few weeks you've been plodding your way through the famous Science-Fiction trilogy Red Mars, Green Mars, Blue Mars (by Kim Stanley Robinson). Every measurement concerning the outside temperature is measured not in Celsius or Fahrenheit, but in units Kelvin. You think it would be fun to write a function Fahrenheit->Kelvin that allows you to take your familiar temperature in Fahrenheit and convert it to a temperature in Kelvin. Write the function, Fahrenheit->Kelvin. This function takes in a single temperature measure in degrees Fahrenheit. NOTE: A measurement in Kelvin is 273 degrees higher than the equivalent measurement in Celsius. 3. Work problem 2.2.4 from "How To Design Programs". This problem appears in the "Variables and Programs" section, page 11 of the text, and online: http://www.htdp.org/2001-01-18/Book/node11.htm Hint: The problem suggests you consult a text. You really should not need an algebra text to see how this conversion works. But if you do, consult a TA.