Assignment 1

Due: Monday, September 28

Question 1

Write a program to convert a measurement given in feet to the equivalent number of
  1. yards
  2. inches
  3. centimeters
  4. meters
Read the number of feet, and print the number of yards, number of feet number of inches, number of centimeters, and number of meters, with appropriate labels.

Sample run

Program to convert number of feet into different units.

Please enter the number of feet> 20

Conversion Table
----------------
20' =   6.67 yards
20' = 240.00"
20' = 609.60 cm
20' =   6.10 m

File name:

convert.cpp

Question 2

Write a program that reads two times in military format (24 clock) and prints the number of hours and minutes between the two times. Hint: Convert the times to the number of minutes past midnight, the calculation is easier. For example 1750 converts to 1070 and 0900 converts to 540, the difference is clearly 530 minutes which is 8 hours and 50 minutes.

You do not need to take into account situations where the second time is smaller than the first time. You should state this requirement to the user.

Sample run

Program to determine the difference between two time values.
Enter times using military format with no spaces or colons between
the hours and minutes (i.e. 1730, not 17 30 or 17:30).

Enter first time: 0900
Enter second time: 1750

The difference is 8 hours and 50 minutes.

File name:

diff.cpp