CSC 160 Fall 2014 - Homework 6 (100 points)
Assigned Oct 13, due MONDAY Oct 20
1) Assignments with time stamps during
class time (Mon or Wed 4:15-5:30pm) will be given a grade of ZERO.
2) 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.
3) 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.
4) In the spirit of the pair
programming article that you read in HW5, this 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).
[50 pts.] Chapter 5B
Read Sections 5.9-5.12 of the textbook. (Typo
on page 82 of printed edition.)
Do the following exercises from the textbook in the same Definitions Pane as the above exercises:
Write an inventory for copies-beside
: Exercise 5.9.2
Finish developing pinwheel
: Exercises 5.9.3 and 5.11.2. Also, you must test the function by following the directions in Exercise 5.12.1
Finish developing lollipop
: Exercises 5.9.7 and 5.11.5. Also, you must test the function by following the directions in Exercise 5.12.1
Submit your Definitions Pane with the filename "ch5bLASTNAMEdef.rkt" and your Interactions Pane with the filename "ch5bLASTNAMEint.rkt".
[30 pts.] Chapter 5C
Read Sections 5.13-5.16 of the textbook.
Do Exercise 5.14.1 from the textbook in DrRacket (Complete all Design Recipe steps (including three test cases with expected answers in quotation marks).
Submit your Definitions Pane with the filename "ch5cLASTNAMEdef.rkt" and your Interactions Pane with the filename "ch5cLASTNAMEint.rkt".
[20 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.
Submit your Definitions Pane with the filename "ch7aLASTNAMEdef.rkt" and your Interactions Pane with the filename "ch7aLASTNAMEint.rkt".
GRADING |
Question |
Point Value |
5.9.2 |
5 |
5.9.3 |
5 |
5.9.7 |
5 |
5.11.2 |
15 |
5.11.5 |
15 |
5.12.1 |
5 |
5.14.1 (contract) |
3 |
5.14.1 (purpose) |
2 |
5.14.1 (examples) |
3 |
5.14.1 (skeleton) |
2 |
5.14.1 (inventory) |
3 |
5.14.1 (fill in body) |
15 |
5.14.1 (testing) |
2 |
7.2.3 |
10 |
7.4.5 |
10 |
Total |
100 |
Last Modified: 10/10/14