Due: Wednesday 9/17 10:00am
Submission name: work05.rkt
Write the Following Functions given the contracts.
Paste the contracts into your racket program when starting. Use define
and lambda
to write your functions. Include test cases with descriptive output.
; (perimFromArea a) --> number
; a : number
; Returns the perimeter of that square whose area is a
; (perimFromArea 25) --> 20
; (perimFromArea 10) --> 12.649110640673518
; (f_to_c temp) --> number
; temp : number
; Returns temp converted from farenheit to celsius
; (f_to_c 212) --> 100
Tip: \(C = (F-32)\dfrac{5}{9}\)
Write contracts and the functions for the following:
cost
- Returns the cost of a ticket to the Totally Real Not Made Up Amazing Museum of Racket Exercises.
- The cost of admission depends on a base amount and a discount rate.
- Cost is calculated by:
base + base * rate
. - Write the function
(cost base rate)
that will return the cost using the formula above. - Example:
(cost 10 0.25)
==>12.5
groupCost
- Returns the total cost of the tickets for a school trip to the Totally Real Not Made Up Amazing Museum of Racket Exercises
- The base cost for students is $5, and the discount rate is 0.5.
- The base cost for teachers is $10, and the discount rate is 0.75.
- The base cost for other adults is $10, and the discount rate is 1.
- Write the function
(groupCost students teachers adults)
that returns the total cost of the tickets given the amounts provided as parameters, using thecost
formula. - Example:
(groupCost 34 2 2)
==>330.0