NOTE: DrRacket saves the work done in the Definitions window only.
As you answer each of the remaining problems, use comments in your file to clearly indicate the number of the problem you are solving.
(* (+ 4 3) 9)You should provide the following comments in the Definitions window:
;; (* (+ 4 3) 9) ;; (* 7 9) ;; 63
(* (- (* 7 3) (- 8 (string-length (string-append "CS" "1101")))) (/ 32 16))
(if (> (double 3) (double (/ 12 4))) (sqrt (+ 4 (* 15 4))) 107)where
double
is defined as
(define (double n) (* n 2))
(require 2htdp/image)Now click the Run button. The functions in the image library are now available to your program.
From the Help menu, choose Help Desk. A browser window will open.
Under the Teaching heading, choose How to Design ProgramsTeachpacks.
In the left margin, click on HtDP/2e Teachpacks.
Here
you will find a description of all the pre-defined functions in the
image.ss
library. Notice the ...search manuals... box at the top of the page. Type in
image-width
to find information about that function. When the DrRacket Helpdesk provides the matches for image-width
, choose the one from "2htdp/image".
Develop a function called four-square that consumes an image and produces an image that consists of 4 copies of the original image, as shown in this example:
if the original image looks like this:
then the produced image should look like this:
Use the DrRacket help desk to learn about the following functions (available in the 2htdp/image library) that you might consider using for this problem:
You may use the image in this problem for testing purposes, or you may test your program with an image of your own choosing (see Google images). Use a square-shaped image. To copy an image, right-click on the image, select Copy, then in the DrRacket Definitions window, select Paste. You should give your image a name using define.
The following terms apply: The principal is the difference between the purchase price of a house and the down-payment. Only the principal is used in the calculation of the interest. The interest is calculated using the formula for simple interest (rate * amount * time). The period of the loan is 30 years, and the interest rate is 4%. Extra bank fees total $1000. The total cost of the house is the purchase price plus the interest paid plus the fees.
You should develop helper functions and define constants as necessary. Make sure each function you define is documented with a signature and a purpose.
Using web-based turnin (see note below), turn in a single file containing all code and documentation for this assignment. Name your file
yourLastName-hw1
For example, if your name is John Doe, you would name your file
doe-hw1
(DrRacket will save it as doe-hw1.rkt
).
In addition, your name and your wpi ccc username must be listed in a comment at the top of your file. Programs submitted after
5pm on Thursday, September 3 will be considered late. No submissions will be
accepted after 5pm on Friday, September 4.