CIS 554 Homework 1

Due Thursday, January 23, 2003






You are to write a program that uses the Time class I discussed in class.
You MAY NOT  make any changes to the class - use it as is.
Use the class whenever possible.
The goals of this assignment are:

1. For this part of the program imagine the setting is a parking garage with cars going in and out.
Create a time object, intime.
Set it to 3:15 pm. in code.  (i.e., no input from the keyboard, hardcode its value.)
Display the time in both the 12 hour and 24 hour format, as part of a sentence, using the member functions for Time.
Eg.,
You entered the parking lot at 3:15PM but if you are not in America you might call it 15:15.
2. Create another Time object, meetingtime.  Ask the user to enter a time in the format ##:##.  (Using the 24 hour clock format.)  Unfortunately you can not read it directly into meetingtime.  (Try and see.)  You can read it as an integer, a character, and another integer.  Try to set meetingtime to this  time.  If it is not a valid time print a message that says you have entered an invalid time and set the meetingtime to 2:00 pm.  The Set functions figure out if a time is valid - there is no reason for you to repeat their work!  Use the boolean return value to guide your code.  Whether valid or not, display the time of the meeting.  The computer's format for printing the time might be ugly, but use it.
Eg.
(good input)
Please enter the time of the meeting: 18:25
The meeting will be at 18:25.


(bad input)

Please enter the time of the meeting: 28:25
That is not a valid time.  The meeting will be at 14:0.
3. Create another Time object, elapsed.
If intime is before meetingtime, set elapsed to the time from intime to the meetingtime.
Print that you entered before the meeting by an amount stored in elapsed.
Eg.
You entered 4:20 before the meeting..
If intime is later than meetingtime, say you will be late and use elapsed to tell how late you will be.
Eg.
You will be late to  the meeting by 2:14.
Sample output 1:
You entered the parking lot at 3:15PM but if you are not in America you might call it 15:15.
Please enter the time of the meeting: 18:25
The meeting will be at 18:25.
You entered 3:10 before the meeting
Sample output 2:
You entered the parking lot at 3:15PM but if you are not in America you might call it 15:15.
Please enter the time of the meeting:  34:67
That is not a valid time.  The meeting will be at 14:00.
You will be late to the meeting by 1:15.
 
Your program should be designed to handle different times, not just the examples used above.