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.)

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 14PE
icon
Related questions
Question

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.)

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 6 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning