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 lab3]$ ./conflict
Class 1 start time:
8:30
Class 1 end time:
9:45
Class 2 start time:
13:00
Class 2 end time:
14:00
Class 1 runs from 08:30 to 09:45.
Class 2 runs from 13:00 to 14:00.
No conflict.
The user will enter all times as they would appear on a 24-hour digital clock: 1:00 PM would be entered as 13:00. 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 15:00 doesn't conflict with a class that starts at 15:00.
The user will always input an integer followed by a non-digit character followed by another integer. The integers may or may not contain leading zeros: 09:7 should be read the same as 9:07. The time entered may not be valid; a time is invalid if:
The hour is not between 0 and 23(inclusive).
The minute is not between 0 and 59(inclusive).
The separator is not a colon (:, ASCII code 0x3a).
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 lab3]$ ./conflict
Class 1 start time:
87:00
Invalid time; try again.
Class 1 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 re-enter both times. This could happen for either of the classes.
[wendy@neverland lab3]$ ./conflict
Class 1 start time:
11:30
Class 1 end time:
11:30
Start time must be later than end time; try again.
Class 1 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 00:00,1:00 AM should print as 01:00,1:00 PM as 13:00, 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 re-enter that one time. If the user enters an invalid class, they should only need to re-enter 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!