Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I want to know if somebody has a solution for this problem: Write a program that

ID: 664205 • Letter: I

Question

I want to know if somebody has a solution for this problem:

Write a program that inputs a time from the console. The time should be in the format"HH:MM AM" or "HH:MM PM". Hours may be one or two digits,for example,"1:10 AM" or "11:30 PM". Your program should include a function that takes a string  parameter containing the time. This function should convert the time into a four-digit military time based on a 24-hour clock. For example,"1:10 AM" would output "0110 hours", "11:30 PM" would output "2330 hours", and "12:15 AM" would output "0015 hours". The function may either write the time to the console or return a string to be written to the console by the main function.

Input Notes: There must be no spaces around the colon. The minutes (MM) must be two digits but the hours may be one or two digits (including a leading zero). There may be zero, one or more spaces before the "AM/"PM" specifier.

Output Notes (Prompts and Labels): Input is prompted by "Enter a time in 'HH:MM AM' or 'HH:MM PM' format: ". Output is of the form:
        In military format, 'inputtime' is 'militarytime'.

Explanation / Answer

Please enter the time: 1: 10

Military time: 0110

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote