CSC 160 Spring 2014 - Homework 11 (100 points)
Assigned Apr 28, due MONDAY May 5

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 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.


[60 (+20) pts.] Chapter 15C
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):
  • 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?.]
  • EXTRA CREDIT (20 pts.): Exercise 15.7.3 from the textbook: Design the make-shape function. (You may use a nested conditional OR design helper functions. Your choice!)

    Save the Definitions Pane to your computer or flash drive with the filename "hw11[LastName]Def.rkt". Do not submit this file yet as you will continue working in the same file for the next part of this assignment!


    [40 pts.] Chapter 19
    Read Chapter 19 of the textbook.

    Do the following exercises in DrRacket (show all Design Recipe v2 steps whenever you design a function):
  • 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).

  • Submit your Definitions Pane with the filename "hw11[LastName]Def.rkt".



    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
    15.7.3 +20
    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 + 30




    Last Modified: 4/21/14