Question: Create a new file called conflict.cpp . In this file, write a program that asks the user for the start and end times of two
Create a new file called conflict.cpp In this file, write a program that asks the user for the start and end times of two classes. It then prints the times that it receives, and tells the user whether or not the two classes conflict.
wendy@neverland lab$ conflict
Class start time:
:
Class end time:
:
Class start time:
:
Class end time:
:
Class runs from : to :
Class runs from : to :
No conflict.
The user will enter all times as they would appear on a hour digital clock: : PM would be entered as : If the classes overlap at all, your program should report a conflict by printing Conflict! Otherwise, print No conflict. Two classes must overlap for at least one minute in order to conflict: a class that ends at : doesn't conflict with a class that starts at :
The user will always input an integer followed by a nondigit character followed by another integer. The integers may or may not contain leading zeros: : should be read the same as : The time entered may not be valid; a time is invalid if:
The hour is not between and inclusive
The minute is not between and inclusive
The separator is not a colon : ASCII code xa
If the user enters an invalid time, your program should say so and prompt again. This could happen at any of the four time prompts.
wendy@neverland lab$ conflict
Class start time:
:
Invalid time; try again.
Class start time:
The user might also enter an end time that isn't later than the start time. In this case, your program should note the error and have the user reenter both times. This could happen for either of the classes.
wendy@neverland lab$ conflict
Class start time:
:
Class end time:
:
Start time must be later than end time; try again.
Class start time:
Hints
You'll be reading a lot of times. Write a function to do this!
You'll also be printing a lot of times. Write a function to do this too.
Your program should always print times with two hour digits. Midnight should print as :: AM should print as :: PM as : etc. The std::setw and std::setfill helpers from the iomanip header will make this easier.
Life will be much better if can represent a time in a single variable. Pick a smart representation that lets you do this. Don't use global variables!
Classes may start or end at midnight, but they'll never cross it
If the user enters an invalid time, they should only need to reenter that one time. If the user enters an invalid class, they should only need to reenter the start and end times for that one class.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
