Write a program that converts a time in 12-hour format to 24-hour format. The program will prompt the user to enter a time in HH:MM:SS AM/PM form. (The time must be entered exactly in this format all on one line.) It will then convert the time to 24 hour form. You may use a string type to read in the entire time at once including the space or you may choose to use separate variables for the hours, minutes, seconds and AM/PM. Run your program and show the output for each of the five examples below. Examples: Input (12HR) Output (24hr) 5:30:00 PM 17:30:00 6:45:50 AM 06:45:50 12:32:30 AM 00:32:30 12:15:18 12:15:18 PM 1:02:22 PM 13:02:22

Question

C++ programming

Write a program that converts a time in 12-hour format to 24-hour format. The program will prompt the user
to enter a time in HH:MM:SS AM/PM form. (The time must be entered exactly in this format all on one line.)
It will then convert the time to 24 hour form. You may use a string type to read in the entire time at once
including the space or you may choose to use separate variables for the hours, minutes, seconds and AM/PM.
Run your program and show the output for each of the five examples below.
Examples:
Input (12HR)
Output (24hr)
5:30:00 PM
17:30:00
6:45:50 AM
06:45:50
12:32:30 AM
00:32:30
12:15:18
12:15:18 PM
1:02:22 PM
13:02:22

Image Transcription

Write a program that converts a time in 12-hour format to 24-hour format. The program will prompt the user to enter a time in HH:MM:SS AM/PM form. (The time must be entered exactly in this format all on one line.) It will then convert the time to 24 hour form. You may use a string type to read in the entire time at once including the space or you may choose to use separate variables for the hours, minutes, seconds and AM/PM. Run your program and show the output for each of the five examples below. Examples: Input (12HR) Output (24hr) 5:30:00 PM 17:30:00 6:45:50 AM 06:45:50 12:32:30 AM 00:32:30 12:15:18 12:15:18 PM 1:02:22 PM 13:02:22

Expert Answer

Want to see the step-by-step answer?

See Answer

Check out a sample Q&A here.

Want to see this answer and more?

Step-by-step answers are written by subject experts who are available 24/7. Questions are typically answered in as fast as 30 minutes.*

See Answer
*Response times vary by subject and question complexity. Median response time is 34 minutes and may be longer for new subjects.
Tagged in
EngineeringComputer Science

Object Oriented Programming

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A

Q: define virtual memory

A: Virtual memory, in context with computing, is memory management technique that is used by the operat...

Q: Find a regular grammar that generates the language on Σ = {a, b} consisting of all strings with no m...

A: Regular grammar for the language Σ = {a, b} is as follows:

Q: (a) Find an nfa with three states that accepts the language L = {an : n ≥ 1} ∪ {bmak : m ≥ 0, k ≥ 0}

A: Graphical representation of NFA:The starting state is denoted by an empty incoming arc, the vertices...

Q: How do I get values from a dictionary into a Python code when my values are in a .txt file?

A: Program instructions:Initialize a dictionary variable named "dictionary" and use open() function to ...

Q: Write a function is_mirror(s) that takes as input a string s and returns True if s is a mirrored str...

A: The algorithm for the program would be as follows:Find the length of the program if it is even lengt...

Q: Using adders, subtracters, comparers, copiers, or multipliers, draw block diagrams for Turing machin...

A: Solution:Turing machine:The Turing machine is theoretical computing machine that can be used to iden...

Q: how can I write a statement in C++ that would print last name, followed by a comma, followed by firs...

A: Given below is the C++ program to print a statement with last name, followed by comma, followed by f...

Q: Hello! I am trying to write a program in Pynthon. Need help. Requirements: Write a .py file like Kev...

A: Program Plan:Import required packagesPrompt the path and the number of characters to delete from the...

Q: What language is accepted by the Turing machine whose transition graph is in the figure below?

A: Turing machine:Turing machine is a model of a hypothetical computing machine which can use a predefi...