Topical Information

This project will let you prove your mastery of input, functions (especially reference arguments), and (hopefully) program design.

Program Information

Write a program that allows the user to enter two times (which are within the same day). Once you've read their times, then you should tell the user what the difference of those times is (i.e. tell the number of hours and minutes [strictly] between the two ...and why not tell them the number of [whole] minutes between them as well).

Make sure they can enter their times in standard, military (i.e. 24-hour) format.


As an example, you might have the program interaction look something like (the parts in this color are typed by the user):

$ ./time.out

                 Welcome to the Time Calculation Program!!!

What is your first time?  12:40

What is your second time?  18:24

There are 343 minutes between the two times (345 inclusive).

That's the same as 5 hours and 43 minutes (or 5:45 inclusive).

Oh...and that's also 5.716667 hours (or 5.75 inclusive).

Thank you for using the TCP!!

Endeavor to have a turbulent day!

$ ./time.out

                 Welcome to the Time Calculation Program!!!

What is your first time?  13:20

What is your second time?  18:24

There are 303 minutes between the two times (305 inclusive).

That's the same as 5 hours and 3 minutes (or 5:05 inclusive).

Oh...and that's also 5.05 hours (or 5.083333 inclusive).

Thank you for using the TCP!!

Endeavor to have an ebullient day!

$

Please notice that the differences displayed are a) exclusive and b) inclusive. That is, the first one does not include the times themselves and the second one includes both of the 'end' times.

Hint: Create re-usable functions to save yourself effort.

Hint: You'll probably end up with at least 4 functions (including main; not including options). But having more than that is NOT a problem!!!

Thought Provoking Questions

  1. How can you get the '0' to print in front of times with only one digit (like the 5:05 in the second run above)? It seems there must be some way to have cout automatically fill this in for us...*ponder*
  2. How many functions did you write for this program? (I see at least 4...) Describe each briefly — explain what needs to come into each function, what it sends back out, and its general purpose. (Hmm... Pretty much the same things you'll be putting in those function comments above both of the function's heads...odd, that.)
  3. How are reference arguments used in this program? (On what function(s)? How many references on each function?) (And, yes, this means you need to be using reference arguments!)
  4. Describe the flow of information in this program. Where does the data start? Where do variables exist? How is data passed from one function to another? Where are references made? Where are copies of data made? (See the notes for the pertinent example to get a better idea of what 'data flow' is.)
  5. How can you get the program to print a random message at the end of every run?

This assignment is (Level 3.5).

Options


Total Level Possible

If you did all above options, this lab could be worth as much as (Level 13.5).