CSC 160 Spring 2015 - Homework 6 (100 points)
Assigned Mar 23, due MON Mar 30

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


[25 pts.] Chapter 7A
Read Sections 7.1-7.6 of the textbook.

Do exercise 7.2.3 from the textbook in DrRacket's Definitions Pane:
  • Define the variable fnord to be 5, snark to be 12, and boojum to be -4.
  • Write a Racket expression in the Definitions Pane to represent the "standard" algebraic expression fnord + snark ÷ boojum. Note: Remember the Order of Operations from math (Parentheses, Exponents, Multiplication/Division, Addition/Subtraction) when translating this from Math (infix) to Racket (prefix).
  • State what the right answer "should be" in quotation marks next to the expression - not next to the variable definitions.
  • Test if you are right by clicking Run.
  • Test your expression again by defining each of the 3 variables with different values, and predicting what the right answer should be. Note: This requires first commenting out your previous expressions and definitions for 7.2.3, since you cannot define the same variable twice.

    Do exercise 7.4.5 from the textbook in DrRacket using the three-step "recipe for converting from infix to prefix" in Section 7.4:
  • Define the variable x to be 27.
  • Write a Racket expression to represent the standard arithmetic expression "square root of 3x". Note: For this exercise, you are required to show the result of each step of the "recipe".
  • State what the right answer "should be" in quotation marks next to the expression - not next to the variable definition.
  • Test if you are right by clicking Run.

    Do exercise 7.6.3 (NOT in textbook): Write the contract for the predefined expt function. For each argument, include its data type then describe what that argument is in parentheses.

    Submit your Definitions Pane with the filename "ch7aLASTNAMEdef.rkt" and your Interactions Pane with the filename "ch7aLASTNAMEint.rkt".


    [75 pts.] Chapter 7B
    Read Section 7.7 of the textbook.

    Do the following exercises from the textbook in DrRacket and submit all Design Recipe steps:
  • Exercise 7.7.2: rect-perimeter
  • Exercise 7.7.15: celsius->kelvin
  • Exercise 7.7.16: fahrenheit->celsius
  • EXTRA CREDIT-Exercise 7.7.14: at-most-10

  • Submit the Definitions Pane with the filename "ch7bLASTNAMEdef.rkt" and your Interactions Pane with the filename "ch7bLASTNAMEint.rkt".


    GRADING
    Question Point Value
    7.2.3 10
    7.4.5 10
    7.6.3 5
    7.7.2 (Contract) 3
    7.7.2 (Purpose) 2
    7.7.2 (3 Examples) 3
    7.7.2 (Skeleton) 2
    7.7.2 (Inventory) 3
    7.7.2 (Function Definition) 10
    7.7.2 (Testing/Interactions Pane) 2
    7.7.15 (Contract) 3
    7.7.15 (Purpose) 2
    7.7.15 (3 Examples) 3
    7.7.15 (Skeleton) 2
    7.7.15 (Inventory) 3
    7.7.15 (Function Definition) 10
    7.7.15 (Testing/Interactions Pane) 2
    7.7.16 (Contract) 3
    7.7.16 (Purpose) 2
    7.7.16 (3 Examples) 3
    7.7.16 (Skeleton) 2
    7.7.16 (Inventory) 3
    7.7.16 (Function Definition) 10
    7.7.16 (Testing/Interactions Pane) 2
    7.7.14 +20
    Total 100 + 20




    Last Modified: 3/22/15