Project 2 - Time Calculator: Objective
Project 2 - Time Calculator: Objective
Objective
Problem
You have been hired by a local mechanical watch company. They are interested in expanding to
digital watches to grow their business. The would like you to write a program which can set the
current time, calculate time deltas, and display times.
Specifications
For your program, you will need to implement the following functions:
In this project, the current time should be stored in 24-hour format. Only when the user
actually interacts with the program will the output and input be sometimes in 12-hour
format.
Implement a main menu that will allow the user to (1) enter the current time, (2) add a
forward delta to the current time, (3) add a backwards delta to the current time, (4)
display the current time, (5) toggle the interface mode between 24-hour and 12-hour
(should impact both getTime and printTime).
The program should identify invalid input for the main menu. When entering the current
time, only allow hours between 0 and 23 and minutes between 0 and 59. Accept only a
and p when entering the time in 12-hour mode.
When entering time deltas, only allow positive values or 0 (this is true for both forward and
backwards time deltas).
1 - Enter a time
2 - Add delta to time
3 - Subtract delta from time
4 - Display current time
5 - Toggle 24-hour mode
6 - Exit
> 4
The current time is 05:50
1 - Enter a time
2 - Add delta to time
3 - Subtract delta from time
4 - Display current time
5 - Toggle 24-hour mode
6 - Exit
> 2
Enter an increment of hours and minutes (separated by a space): 0 120
The new time would be 07:50
1 - Enter a time
2 - Add delta to time
3 - Subtract delta from time
4 - Display current time
5 - Toggle 24-hour mode
6 - Exit
> 2
Enter an increment of hours and minutes (separated by a space): 2 20
The new time would be 08:10
1 - Enter a time
2 - Add delta to time
3 - Subtract delta from time
4 - Display current time
5 - Toggle 24-hour mode
6 - Exit
> 5
12-hour mode turned on
1 - Enter a time
2 - Add delta to time
3 - Subtract delta from time
4 - Display current time
5 - Toggle 24-hour mode
6 - Exit
> 1
Enter the time with whitespace separating the hours, minutes, and either 'a' for am or
'p' for pm: 0 15 a
1 - Enter a time
2 - Add delta to time
3 - Subtract delta from time
4 - Display current time
5 - Toggle 24-hour mode
6 - Exit
> 4
The current time is 12:15 am
1 - Enter a time
2 - Add delta to time
3 - Subtract delta from time
4 - Display current time
5 - Toggle 24-hour mode
6 - Exit
> 3
Enter a decrement of hours and minutes (separated by a space): 1 15
The new time would be 11:00 pm
1 - Enter a time
2 - Add delta to time
3 - Subtract delta from time
4 - Display current time
5 - Toggle 24-hour mode
6 - Exit
> 3
Enter a decrement of hours and minutes (separated by a space): 0 90
The new time would be 10:45 pm
1 - Enter a time
2 - Add delta to time
3 - Subtract delta from time
4 - Display current time
5 - Toggle 24-hour mode
6 - Exit
> 6
Exiting...
Tips
Make sure to write your other functions before you write your int main.
When implementing each function, make sure to test all edge cases. This is especially important
for the rollForward and rollback functions as they have perhaps the most complicated
functionality of any of the functions used in this project.
Deliverables
(15 points) A project report discussing what your program does, how it does it, and why you
designed it the way you did. Reflect on how the project would be different if you had not used
loops and functions methods. Shoot for something in the 1-2 page range. PDF format.
(85 points) Your c++ source code (the .cpp file). Make sure to name it
project2_yourlastname.cpp.