On this page:
sum-coins
area-cylinder
area-pipe1
area-pipe2
tax
netpay
what-kind
time
time-diff
position
circ
square
rect
area
translate-shape
in-shape?

3.3 Basic Racket

You must complete this assignment by yourself.

You must submit this in an archive named "basic.zip". This archive must contain a folder named "basic". This folder must contain all the files specified below. You must attach "basic.zip" to an email whose subject is "BYU - Fall 2010 - CS 330 - basic" and whose message body contains the name of everyone on your team (each on a separate line.) You must send this email to jay@cs.byu.edu before 5pm (Provo time) on 9/2. Ensure that what you are satisfied with what you submit, because only your chronologically first submission will be graded. Ensure that you follow these instructions exactly, since submissions that do not meet these requirements (i.e. do not have the correct format) will receive no credit, despite the time and energy you put into the assignment. Please see Turn In Policy for more information.

You must submit this in a file named "basic.rkt".

Develop the following functions and datatypes in the Beginning Student language.

(sum-coins pennies nickels dimes quarters)  number?
  pennies : number?
  nickels : number?
  dimes : number?
  quarters : number?
The local supermarket needs a program that can compute the value of a bag of coins. sum-coins produces the amount of money in the bag.

(area-cylinder base-radius height)  number?
  base-radius : number?
  height : number?

You will want to use check-within to test this.

(area-pipe1 inner-radius    
  length    
  wall-thickness)  number?
  inner-radius : number?
  length : number?
  wall-thickness : number?
Computes the surface area of a pipe, which is an open cylinder.

You will want to use check-within to test this.

(area-pipe2 inner-radius    
  length    
  wall-thickness)  number?
  inner-radius : number?
  length : number?
  wall-thickness : number?
Write a version of area-pipe1 that uses several helper functions.

You will want to use check-within to test this.

(tax gross-pay)  number?
  gross-pay : number?
Produces the amount of tax owed. For a gross pay of $240 or less, the tax is 0%; for over $240 and $480 or less, the tax rate is 15%; and for any pay over $480, the tax rate is 28%.

(netpay hours-worked)  number?
  hours-worked : number?
Determines the net pay of an employee, which is the gross pay minus the tax. Assume the hourly pay rate is $12.

(what-kind a b c)  symbol?
  a : number?
  b : number?
  c : number?
The function consumes the coefficients a, b, and c of a quadratic equation. It then determines whether the equation is degenerate and, if not, how many solutions the equation has. The function produces one of four symbols: 'degenerate, 'two, 'one, or 'none. An equation is degenerate if (= a 0).

(struct time (hours minutes seconds)
  #:extra-constructor-name make-time)
  hours : number?
  minutes : number?
  seconds : number?
Represents points in time since midnight. Define using define-struct.

(time-diff t1 t2)  number?
  t1 : time?
  t2 : time?
Returns the number of seconds from t1 to t2.

(struct position (x y)
  #:extra-constructor-name make-position)
  x : number?
  y : number?
Represents two dimensional points.

(struct circ (center radius)
  #:extra-constructor-name make-circ)
  center : position?
  radius : number?
Represents circles.

(struct square (upper-left length)
  #:extra-constructor-name make-square)
  upper-left : position?
  length : number?
Represents squares.

(struct rect (upper-left width height)
  #:extra-constructor-name make-rect)
  upper-left : position?
  width : number?
  height : number?
Represents rectangles.

(area shape)  number?
  shape : (or/c circ? square? rect?)
Computes the area of the shape.

You will want to use check-within to test this.

(translate-shape shape delta)  (or/c circ? square? rect?)
  shape : (or/c circ? square? rect?)
  delta : number?
Produces a shape whose key position is moved by delta pixels in the x direction.

(in-shape? shape p)  boolean?
  shape : (or/c circ? square? rect?)
  p : position?
Returns true if p is within the shape, false otherwise.