Lab5: Week of Feb 02-08
 


1. Write a unit conversion program. Ask the user from which unit they
want to convert to another unit. The units are floz (fluid ounce), oz
(ounce), gal (gallon), lb (pound), in (inch), ft (foot), mi (mile), kg,
ml (milli litre), l (litre), g (gram), mm, cm, m, km. Reject
incompatible conversions such as kg to mm. Ask the value to be converted
and display the results. The dialogue should look something like
(however, you are encouraged to innovate!):

Convert from?
gal
Convert to?
ml
Value?
2.5

2.5 gallon = 9462.5 ml

Another conversion (type yes or no)?
xyz
type yes or no
yes
.
.
.
.

2. Time can be specified in military notation using four digits. For
example 11.30pm is represented as 2330. Write a program which given
start time and end time finds out the time difference between these. For
example if start time is 1330 and end time is 1800 then the output
should be: 4 hours 30 minutes. Note that the second number can be
smaller than the first number. For example start time 2300 and end time
0100 should give an answer: 2 hours.

3. Write a program to compute cube root of a number x using the fact that
if p is an approximation for cube root of x then q = (2p+x/(p*p))/3 is a
better one.