CS 135 Fall 2011
Becker, Goldberg, Kaplan, Tompkins, Vasiga
Assignment:
1
Due:
Tuesday, September 20, 2011 9:00 pm
Language level:
Beginning Student
Files to submit:
constants.rkt
,
functions.rkt
,
speed.rkt
,
grades.rkt
,
stars.rkt
Warmup exercises:
HtDP 2.4.1, 2.4.2, 2.4.3, and 2.4.4
Practice exercises:
HtDP 3.3.2, 3.3.3, and 3.3.4
For this and all subsequent assignments the solutions you submit must be entirely your own work.
Do not look up either full or partial solutions on the Internet or in printed sources. Please read the
course Web page for more information on assignment policies and how to submit your work. Make
sure to follow the style and submission guide available on the course web page when preparing your
submissions. Your solutions for assignments in this course will be graded both on correctness and
on readability, meaning that, among other things, you should use constants and parameters with
meaningful names.
Note that for this assignment only, you do not need to include the design recipe in your solutions.
A wellwritten function definition is sufficient.
If you have not yet received full marks for Assignment 0: You may submit this assignment
(and subsequent assignments), but it will be ignored unless you obtain full marks for Assign
ment 0 before this assignment’s due date.
Each assignment will start with a list of warmup exercises. You don’t need to submit these, but
we strongly advise you to do them to practice concepts discussed in lectures before doing the
assignment. This week’s warmup exercises are HtDP exercises 2.4.1, 2.4.2, 2.4.3, and 2.4.4.
Here are the assignment questions you need to submit.
1. Translate the following constant definitions into Scheme. Place your solutions in the file
constants.rkt
.
Note that for this question only, you will
not
be able to
Run
this
DrRacket file.
For example, if we asked you to translate the definition:
mean
=
x
1 +
x
2
2
you would submit:
(
define
mean
(
/
(
+
x1 x2
)
2
))
(a) An example from finance (
future value
):
FV
=
PV
·
(1 +
rate
)
n
CS 135 — Fall 2011
Assignment 1
1
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
(b) An example from geometry (the
inradius of a diamond
):
radius
=
a
·
b
√
a
2
+
b
2
(c) An example from algebra (the
harmonic mean
):
HM
=
2
1
v
1
+
1
v
2
2. Translate the following function definitions into Scheme. Place your solutions in the file
functions.rkt
.
(a) An example from genetics (the
Haldane equation
):
C
(
x
) =
1
2
(
1

e

2
·
x
)
(Hint: recall from Assignment 0 the builtin Scheme function that produces
e
x
.)
(b) An example from geometry (the
area of a triangle
)
area
(
a, b, t
) =
1
2
·
a
·
b
·
sin(
t
)
(c) An example from physics (
ballistic motion
):
height
(
v, t
) =
v
·
t

1
2
·
g
·
t
2
where
g
is the constant
9
.
8
(acceleration due to gravity)
3. The above constant
9
.
8
represents the acceleration due to gravity in units of metres per
second squared (
m/s
2
).
This is a metric unit; in the United States, socalled “imperial”
units are usually used instead of metric. There, the constant
g
would likely have the value
of
32
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '07
 VASIGA
 Irrational number, exact numbers

Click to edit the document details