Name: ____________________________________________________ Alpha: ________________________

Describe help received: _____________________________________________________________________

Print this homework sheet, bring it to the class, and turn it in right before the next lecture starts.

  1. (100 pts) Write a program that reads in two lengths in the format x' y'' (i.e. x feet y inches) and returns the difference in length between the two in the same format. You may assume that the first is always larger than the second!

    You MUST name your program hw.cpp. To avoid confusion, place this a ic210/hw04 directory.

    Note that the user types in two apostrophe characters after the number of inches, NOT a single "double-quote" character.

    A typical run of your program should look EXACTLY like this (user input shown in red):

    Enter two lengths in feet and inches (larger first!)
    32' 6''
    15' 11''
    Difference is 16' 7''
    These should be stapled together.
    • Hint 1: First work on getting your program simply read the four measurement values, then work on getting it to print out the difference in inches, then work on getting the difference in feet and inches.
    • Hint 2: The string constant "'" works just fine, but to get the character constant of the apostrophe you must write '\'', which uses the backslash as an escape character.
    • Hint 3: For ideas on how to chop a length in inches into feet and inches, look at the Minutes and Seconds program, which has to deal with the similar problem of chopping a time in seconds up into minutes and seconds.
WARNING The "submit" system will accept only a small number of submissions from you for each homework (3, in this case, soon to be fewer!). So be sure to TEST your program for (a) accuracy and (b) exact matching of the desired output. For "accuracy", be sure to try some *additional* test cases, beyond the one that is shown above!

Submit (your file must use the filename shown!)
~/bin/submit -c=IC210 -p=hw04 hw.cpp
Turn in a printout of this cover sheet and the codeprint of hw.cpp.