Write a program that converts c) 12-hour time to military time to and d) military time to 12-hour time. By 12-hour time, I mean times with an AM/PM. For this problem we can assume that all 12-hour times are formated as in the following examples “3 14 AM”, “12 15 PM”, “12 59 AM”. Note that there is a space (not a colon) in between the hours and minutes and the AM/PM. Also note that we are capitalizing AM and PM. For part c, you can assume that the user enters in this format. Military time is a 24-hour time with no colon or space in between the hours and minutes, e.g. 1514 for 3:14 PM. (It is okay if your solution to part c sometimes outputs a 3-digit number such as 306 for 3 06 AM.) (you can't use “if” statements.)
Write a program that converts c) 12-hour time to military time to and d) military time to 12-hour time. By 12-hour time, I mean times with an AM/PM. For this problem we can assume that all 12-hour times are formated as in the following examples “3 14 AM”, “12 15 PM”, “12 59 AM”.
Note that there is a space (not a colon) in between the hours and minutes and the AM/PM. Also note that we are capitalizing AM and PM. For part c, you can assume that the user enters in this format. Military time is a 24-hour time with no colon or space in between the hours and minutes, e.g. 1514 for 3:14 PM. (It is okay if your solution to part c sometimes outputs a 3-digit number such as 306 for 3 06 AM.) (you can't use “if” statements.)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 6 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)
![C++ Programming: From Problem Analysis to Program…](https://www.bartleby.com/isbn_cover_images/9781337102087/9781337102087_smallCoverImage.gif)