![]() |
C211 Lab 2: ACME Sports DrinksHelp the company figure out if it can ship all of the drink it makes each day! |
![]() |
In this lab, you will calculate how many cans, boxes, and trucks ACME will need in order to ship all of its drink each day. If at any time you have any questions, please raise your hand or ask your neighbor.
volume->canscyl-vol (the procedure I just made in class).
It should start with:
(define cyl-vol
(lambda (rad ht)
...))
HINT: copy it from the board!
cyl-vol
and begin:
(define vol->cans
(lambda (vol can-rad can-ht)
...))
Fill in the "..." with code that uses the cyl-vol
procedure to calculate the volume that will fit in each can, then figures
out how many cans it will need. can-rad & can-ht
are the radius and height of a can (respectively).
ceiling. It
rounds any non-whole number up. For example, 3.2 becomes 4.0 and 3.6
becomes 4.0.
As you can see, this means that 28 cans of radius 2 and height 4 are needed to pack 1400 units of Sports Drink.> (vol->cans 1400 2 4) 28.0
cans->boxesvol->cans, this should be cake.
Now you must write a procedure that returns the number of boxes needed
to pack a given amount of cans.
cans->boxes. It should begin like:
(define cans->boxes
(lambda (cans box-capacity)
...))
The parameter box-capacity represents the number of cans that
fit in one box.
boxes->trucksboxes->trucks. It should begin like:
(define boxes->trucks
(lambda (boxes truck-capacity)
...))
NOTE: Remember ceiling? Recall also that even if there
is one box more than it takes to fill a truck, a second truck must be
used. If there are (+ 1 truck-capacity) boxes, it takes
two trucks to move the whole lot!
volume->trucks that takes as parameters:
volume of Sports Drink#<procedure> that converts volume into cans
(step 1)#<procedure> that converts cans into boxes
(step 2)#<procedure> that converts boxes into
trucks (you guessed it, step 3!)volume.
volume->trucks-noprocs)
in step 4 so that the only parameter it takes is volume
Then answer these questions in your lab book:
enough-drivers?
without using the if keyword
that returns #t if there are enough truckers and
#f if there aren't. Your procedure should start like this:
(define enough-drivers?
(lambda (num-drivers vol)
...))
Feel free to use either procedure from steps 4 or 4.1, but be sure
to explain why you picked the one you did.
if keywordenough-drivers?
predicate and based on the results either prints out:
orToday we have enough trucks to ship ## units of Sports Drink!
(Where the ## is the actual volume of Sports Drink)
We need ## more drivers to ship today's volume of Sports Drink.
(Where the ## here is the additional number of drivers needed to complete the shipment)
if and vol->trucks...