CSC 160 Fall 2013 - Homework 13 (100 points)
Assigned Dec 2 & 4, due MONDAY Dec 9

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 HW6, 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 Definitions Pane.
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/2
Textbook Reading (to review today's class):
  • Read Sections 15.7-15.10 and 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 set of test cases and a Data Analysis):
  • 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 (up to p.257) of the textbook.


    Assigned W 12/4
    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."
         ---Make sure to test your function.
  • 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 (up to p.257) of the textbook.



    Submitting your Assignment
    You are required to submit the square-root exercise in a single Definitions Pane. You are required to submit the remaining exercises in a single Definitions Pane. Submit both 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 you submit.

    The file names for the Definitions Panes need to be "hw13[LastName]Def.rkt" and "hw13[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 "hw13WittensteinDef.rkt" and "hw13WittensteinDefSquareRoot.rkt"

    If these filenames are not used, points will be deducted from the assignment grade.


    GRADING
    Question Point Value
    15.8.2 30
    Contract 2
    Purpose 1
    Data Analysis 5
    Examples 6
    Skeleton w/Inventory 3
    Add details to skeleton 3
    Fill in the Function Body 10
    15.8.3 30 (+10)
    Contract 2
    Purpose 1
    Data Analysis 5
    Examples 6
    Skeleton w/Inventory 3
    Add details to skeleton 3
    Fill in the Function Body 10
    big-v2? 12
    square-root 28
    Contract 2
    Purpose 1
    Data Analysis 5
    Examples 4
    Skeleton w/Inventory 3
    Add details to skeleton 3
    Fill in the function body 10
    Total 100




    Last Modified: 12/4/13