Note change of due date: since I'll be out of town for the weekend, the homework is to be e-mailed to me, dated no later than 11:59 PM Monday, May 30.
Fill out the pre-semester background survey on the Web.
Read, in How to Design Programs, from the preface through chapter 2 (by Tuesday), chapter 3 (by Wednesday), and chapter 4 (by Thursday).
Skim Adages on Software Design and Development (I expect you to read all this stuff eventually, at your own pace.)
Write a few paragraphs on your reaction to the above reading assignments, and turn them in by email to Dr. Bloch. Be sure to include your name!
For all the programming assignments, be sure to follow the design recipe. Write your function contract, examples, and function definition in the Definitions Window, save it to a file, and send me this file. Also test your program: since you've already included examples in the Definitions window, you should be able to hit the Execute button and see all the results (along with what you said they "should be"). Save the resulting Interactions window to a text file and send me this file too. Be sure to choose meaningful names for functions and parameters, and watch for opportunities to re-use functions you, I, or the textbook have already written.
Also turn in a log of how many errors of different kinds you encountered in the assignment, with brief comments describing each one ("mismatched parentheses" is self-explanatory, but more complex errors might need more description). You may do this using the PSP forms, or simply by keeping track in a text file or on paper and turning it in.
Develop a function named
hours->minutes
which takes in a number of minutes and
returns the number of seconds in that many minutes.
(We'll probably do this in class.)
Develop a function named
days->hours
which takes in a number of days and returns the
number of hours in that many days.
Develop a function named
days->minutes
which takes in a number of days and returns the
number of minutes in that many days.
Hint: re-use previously-written functions. You should
be able to write this function with no numbers in the definition
(although you'll need numbers in your examples, of course).
Develop a function named
dhm->minutes
which takes in three numbers: how
many days, how many hours, and how many minutes, in that order, and
returns the total number of minutes.
Hint: re-use previously-written functions. You should
be able to write this, too, with no numbers in the definition.
Develop a function named f->c
which
takes in a temperature in degrees Fahrenheit and returns the same
temperature expressed in degrees Celsius. (The formula is C =
(F-32)*5/9; we'll probably do this in class.)
Develop a function named c->k
which
takes in a temperature in Celsius and returns the corresponding number of
degrees Kelvin. (A Kelvin degree is the same size as a Celsius degree, but
Kelvin's 0 is the same as -273 Celsius, so 0 Celsius is 273
Kelvin.)
Develop a function named f->k
which
takes in a temperature in Fahrenheit and returns the corresponding number of
degrees Kelvin. (For example, 32 degrees Fahrenheit is the same as
273 degrees Kelvin.)
Hint: re-use previously-written functions, so you can
do it with no numbers in the definition.
You've just learned that 0 Kelvin is, more accurately, -273.15
Celsius. Make whatever modifications are necessary to
accommodate this more-accurate conversion in both c->k
and
f->k
.
Develop a function named convert-3-digits
which
takes in three numbers (the hundreds, tens, and ones places of a 3-digit
number, in that order) and returns the 3-digit number. For example,
(convert-3-digits 4 2 5)
should return the number 425. Note that Scheme doesn't have an
operation for "put this number next to that one"; you have to use
arithmetic operations like +, -, *, /.
Next, develop a function named
convert-3-reversed
which takes in the ones, tens, and
hundreds places of a 3-digit number, in that order, and returns the
3-digit number. For example,
(convert-3-reversed 5 7 2)
should return the number 275. Hint: re-use an old
function!
Do (but don't turn in) all the exercises from section 2.4 of the textbook (the ones about errors).
Develop a function can-vote?
which takes
in a person's age and returns a Boolean indicating whether that person
is old enough to vote.
Develop a function can-vote-but-not-drink?
which takes in a person's age and returns a Boolean indicating whether
that person is old enough to vote, but too young to drink alcohol.
Download and install the "tiles-world" teachpack:
Develop a function blot
which
takes in an image and a string (a color, e.g. "blue"
,
"red"
, etc.) and returns the same image with the center
covered by an oval of the specified color.
Develop a function that does something fun with images,
using some combination of image-above
,
image-beside
, reflect-vert
,
reflect-horiz
, rotate-cw
,
rotate-ccw
, and rotate-180
.
Survey: /5
(I'm not grading on what you say, only on whether you filled it
out.)
Essay: /30
(Grading primarily on content: convince me that you've read some of
the adages and thought about them.)
Error log: /20
(I'm not grading on how many or how few errors you encountered,
only on whether you recorded them adequately.)
Function name | Contract | Examples | Definition | Test results |
---|---|---|---|---|
hours->minutes |
/5 | /5 | /10 | /5 |
days->hours |
/5 | /5 | /10 | /5 |
days->minutes |
/5 | /5 | /10 | /5 |
dhm->minutes |
/5 | /5 | /10 | /5 |
f->c |
/5 | /5 | /10 | /5 |
c->k |
/5 | /5 | /10 | /5 |
f->k |
/5 | /5 | /10 | /5 |
Modifications | /5 | /10 | /5 | |
convert-3-digits |
/5 | /5 | /10 | /5 |
convert-3-reversed |
/5 | /5 | /10 | /5 |
can-vote? |
/5 | /5 | /10 | /5 |
can-vote-but-not-drink? |
/5 | /5 | /10 | /5 |
blot |
/5 | /5 | /10 | /5 |
Something fun with images | /5 | /5 | /10 | /5 |
Following directions | /10 |
Writing contracts from word problems | /10 |
Choosing examples | /10 |
Choosing names | /10 |
Coding | /10 |
Code re-use and function composition | /10 |