Fill out the pre-semester background survey on the Web.
Fill out the daily survey on the Web, at least once with your name. (In general, I'd like you to fill it out at least once a week, preferably after every class, name optional.)
Read, in How to Design Programs, from the preface through chapter 4 (by Wednesday, Feb. 1).
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 e-mail 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 e-mail 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 hours and
returns the number of minutes in that many hours.
(We did this in class, so just copy it out of your notes.)
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 did this in class too.)
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
. How much of the program did you
need to change?
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.
Develop a function salutation
which takes
in an hour of the day (a number in the range 1-24) and returns one of
the three strings "Good morning", "Good afternoon",
or "Good evening" as appropriate. (Let's say that afternoon
is any time from 12 to 5 inclusive.)
Develop a function reply
which takes in
one of
the three strings "Good morning", "Good afternoon",
or "Good evening", and returns one of the three strings
"Not until I've had my coffee", "I need a nap", or
"When is dinner?" respectively. If the input is a string
other than the three specified, the answer should be "Huh?".
Pre-term Survey: /5
(I'm not grading on what you say, only on whether you filled it out.)
"Daily" Survey: /5
(Ditto.)
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 |
salutation |
/5 | /5 | /10 | /5 |
reply |
/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 |