CSC 160 Fall 2012 - Homework 11
Assigned Dec 3, due MONDAY Dec 10
1) Assignments with time stamps during
class time (Mon or Wed 4:15-5:30pm) will be given a grade of ZERO.
2) In the spirit of the pair
programming article that you read and summarized in HW5, this week's homework assignment may be done in
pairs. If you choose to work in pairs, you must find time outside of
class to work together in person at one computer. As per
the syllabus, you cannot "pair-off" with the same person more than
once during the semester. If you choose to do the
assignment in pairs, please submit one copy through
Moodle where both last names are used in each file
name and both names appear as a comment at the top
of each pane (Definitions and Interactions).
3) Start this homework as soon as
possible so that you have time to get any help you may need
from the instructor or course tutor prior to when the assignment is due.
4) Do not start the exercises until to have fully read and fully
understood the corresponding textbook sections. If there is something you
do not fully understand, you
must contact the instructor or course tutor prior to
starting the assigned exercises.
Assigned M 12/3
Textbook Reading (to review today's class):
Read Sections 15.7-15.10 of the textbook.
Do the following exercises in DrRacket (show all Design Recipe v2
steps whenever you Design a Function, including a sufficient set of test
cases):
Exercise 15.8.2 from the textbook: Design the
size
function.
Exercise 15.8.3 from the textbook: Design the
big?
function. [Hint: The
function needs to handle 2 kinds of input, and for each kind of input there are 2
possible answers and a "borderline", so you'll need 6 test cases.]
[Extra credit (10 points): Calling the size
function twice in
the function body of big?
.]
Textbook Reading (to prepare for next class):
Read Chapter 19 and Sections 20.1-20.4 of the textbook.
Assigned W 12/5
Textbook Reading (to review today's class):
Read Chapter 19 of the textbook.
Do the following exercises in DrRacket (show all Design
Recipe v2 steps whenever you Design a Function, including a sufficient
number of test cases):
Modify the big?
function as follows:
---Copy and paste the function
definition for big?
from Exercise 15.8.3. Change the function name to big-v2?
---Modify the function definition so that it
calls the error
function and returns the message "Sorry, big-v2? only works on numbers and
strings." for any inputs other than numbers or strings.
---Copy and paste the test cases from Exercise
15.8.3. Change the function name in each test case to
big-v2?
.
---Add a test case that will cause the function
to return "Sorry, big-v2? only works on numbers and
strings."
---Test your function in the Interactions
Pane.
Design the square-root
function:
It takes in any
object and does the following:
A) If the object is a non-number, it
returns an error message using the
error
function saying
"Cannot take the square root of a
non-number."
B) If the object is a negative
number, it returns an error message using
the error
function
saying "Cannot take the square root of a negative
number."
C) If the object is a nonnegative
number, it finds the square
root of a number (using sqrt
).
Textbook Reading (to prepare for next class):
Read Sections 20.1-20.4 of the textbook.
Submitting your Assignment
You are required to submit the square-root
exercise in a
single Definitions Pane and a single Interactions Pane.
You are required to submit the remaining exercises in a single Definitions Pane and a single Interactions
Pane.
Submit all 4 of these files on Moodle. Points will be deducted for
submitting the wrong number of files.
Be sure to include your first and last name as a comment in the
first line of each Definitions Pane and Interactions Pane you submit.
The file names for the Definitions Panes need to
be "hw11[LastName]Def.rkt" and "hw11[LastName]DefSquareRoot.rkt" where:
[LastName] is replaced with your last name(s).
For example, if I were submitting this
assignment, I would name the files
"hw11WittensteinDef.rkt" and "hw11WittensteinDefSquareRoot.rkt"
Similarly, the file names for the Interactions Pane need to be
"hw11[LastName]Int.rkt" and "hw11[LastName]IntSquareRoot.rkt".
Please let me know if this is not clear or if you are unsure exactly
what filename to use. Part of your grade is using the correct filenames.
GRADING |
Question |
Point Value |
15.8.2 |
30 |
Contract | 2 |
Purpose | 1 |
Data Analysis | 4 |
Examples | 6 |
Skeleton w/Inventory | 3 |
Add details to skeleton | 2 |
Function | 10 |
Interactions Pane | 2 |
15.8.3 |
30 (+10) |
Contract | 2 |
Purpose | 1 |
Data Analysis | 4 |
Examples | 6 |
Skeleton w/Inventory | 3 |
Add details to skeleton | 2 |
Function | 10 |
Interactions Pane | 2 |
big-v2? |
12 |
square-root |
28 |
Contract | 2 |
Purpose | 1 |
Data Analysis | 4 |
Examples | 4 |
Skeleton w/Inventory | 3 |
Add details to skeleton | 2 |
Function | 10 |
Interactions Pane | 2 |
Total | 100 |
Last Modified: 12/5/12