CS 54 - Lab 5


Demonstration Code

The demonstration code of our function review is here.


Lab Assignment

Suppose you're walking down the beach in Bombay and your trip over a strange metal object. Since you had your military entrenching tool offhand, you decide to dig the object out of the sand. You come to discover that it's a time machine invented by Da Vinci that scholars have not discovered yet. Instead of doing the right thing, you decide to take the time machine for test drive. The only problem is that you're out of fuel. So, like any other good computer scientist, you decide to read the manual. The manual indicates that the tank holds 42 gills of red wine. This begs the question: what is a gill? Well, being the scientist you are, you had your CRC Handbook of Chemistry & Physics right next to your military entrenching tool. And you found out the conversion formula from gills to liters is:
L = 0.1421g
for g gills.


Lab Assignment - Part I (Required - 8 Points)

Write a program that will implement the conversion formula using two functions: double gillsToLiters(double gills), which will take the number of gills and return the number of liters. Then write a function void gillsToLitersRef(double &conversionValue) that will take the number of gills stored in conversionValue by reference and then change conversionValue to the number of liters. Write a simple main() function to test both functions.


Lab Assignment - Part II (Quasi Required - 10 Points)

Da Vinci also noted that in order for the red wine to fuel the time machine, it also needed 3 stones of cheese. You consult your CRC Handbook of Chemistry & Physics and find out that the conversion formula is:
k = 6.35s
for s stones.
Write two more functions as you did in Part I for the stones to kilogram conversion.


Lab Assignment - Part III (Extra Credit - 12 Points)

Da Vinci calculated that the maximum tangential velocity of the time machine was 2.5 chains per second. He also knew the velocity of the time machine over the time space-continuum was 100 years per second (i.e., in one second, the time machine would travel 100 years) times the remaining percentage of tangential velocity (i.e., if we're going 2 chains per second, we have 20% of our tangential velocity remaining). Knowing (from the CRC Handbook of Chemistry & Physics, of course) that 1 chain = 20.1168 m, write two functions: one that will find the tangential velocity in kilometers per hour given the tangential velocity in chains per second and one that will find the time-space velocity given the tangential velocity in chains per second.


Grading & Submission

Part I is worth 8 points. Part II is worth 10 points (Part I + 2 more points). Part III is worth 12 points (Part II + 2 points extra credit). The lab is out of 10 points. When you're done, submit your lab05.cpp file on Blackboard. I will be grading your program on the following criteria:


[Dilbert]