CSC 160 HW4
Assigned 27 Feb, due 13 March
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 as usual and send me the test run(s).
You may put all the problems in one file, or put each problem in a
separate file, at your preference; but if one function depends on
another, keep them in the same file.
Note: For the functions "check-guess", "check-color",
etc. you are expected to test the functions directly as usual, and turn
in the resulting test run, as well as testing them with the
teachpack (for which there's really nothing to turn in).
For the graphics problems in section 6.2, you'll need to test these
yourself, one at a time, using the Interactions window; there is nothing
to turn in for test runs.
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).
This assignment is to be done in pairs, just like homework 3
(but with a different partner).
This is a long assignment. I'm giving you two weeks to do it,
and you'll need two weeks; start immediately!
- Do (but don't turn in) as many of the exercises in
section 4.1,
section 4.2,
and
section 4.3
as you think you need.
- Do
exercise
4.4.2 in How to Design Programs.
- Do
exercise
4.4.3 in How to Design Programs.
- Develop a function ebay-commission to
compute the commission E-Bay charges on an auction. Here are the rules:
The commission is the sum of an "insertion fee" and a "final value
fee". The insertion fee, which depends on the asking price, is computed
as follows:
- If the asking price is $0.01-$9.99, the fee is $.30.
- If the asking price is $10.00-$24.99, the fee is $.55.
- If the asking price is $25.00-$49.99, the fee is $1.10.
- If the asking price is $50.00-$199.99, the fee is $2.20.
- If the asking price is $200.00 or more, the fee is $3.30.
The final value fee, which depends on the selling price, is computed as
follows:
- Compute 5% of the amount up to $25.00.
- If the selling price is over $25.00, add 2.5% of the amount over
$25.00 up to $1000.00.
- If the selling price is over $1000.00, add 1.25% of the amount
over $1000.00.
For example, if the selling price were $20.00, the final value fee would be
$1.00.
If the selling price were $40.00, the final value fee would be
$1.625: 5% of the first $25 makes $1.25, and 2.5% of the next $15 makes
$.375.
If the selling price were $2000.00, the final value fee would be
5% of the first $25, or $1.25, plus 2.5% of the next $975, or $24.375,
plus 1.25% of the remaining $1000, or $12.50, for a total of $38.125.
Hint: You'll almost certainly need to write more
than one function. Each of your functions must have a contract,
examples, etc. In the past, when I've assigned similar problems, many
students (especially the more experienced ones) skipped through the
"contract" part, got it wrong, and everything after that was hopeless.
The moral is follow the design recipe!
Note: I don't think E-Bay actually charges
fractional cents; they round the commission to the nearest cent. You're
not required to do that for this assignment.
- Do
exercise
5.1.2 in How to Design Programs. Test it by playing the
game as described in the textbook.
- Do
exercise
5.1.3 in How to Design Programs. Test it by playing the
game as described in the textbook.
- Do
exercise
5.1.5 in How to Design Programs. Test it by playing the
game as described in the textbook.
- Do all the problems in
section 6.2.
Last modified:
Stephen Bloch / sbloch@adelphi.edu