Your program must keep on prompting the user if an incorrect time was given; see below for examples. The program then converts the time into the usual US format with hours from 1 to 12, the minutes and an AM or PM marker. This conversion works like follows: • 0 hours become 12 o’oclock AM, • 1 through 11 hours become 1 through 11 hours AM, • 12 hours become 12 o’clock PM, • 13 through 23 hours become 1 through 11 hours PM, with a subtraction of 12. The program then displays the time in the usual US format. Please use care when displaying the minutes, as an extra zero needs to be displayed for minutes 0 to 9. See the examples below for details. Examples of input and output: Please enter the hours on a 24 hour clock (0-23): 15 Please enter the minutes (0-59): 7 You entered 3:07PM Please enter the hours on a 24 hour clock (0-23): 27 Please enter the minutes (0-59): 17 Sorry, your input is incorrect. Write a program clock.c that asks the user to input a moment in time as an hour and a minute. The hours are given in a 24 hour (European/Military) format, with hours from 0 to 23. The minutes are given as usual, between 0 and 59.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter5: Repetition Statements
Section5.5: A Closer Look: Loop Programming Techniques
Problem 15E: (Program) Write a program to simulate the rolling of two dice. If the total of the two dice is 7 or...
icon
Related questions
icon
Concept explainers
Question
Your program must keep on prompting the user if an incorrect time was given; see below for examples. The program then converts the time into the usual US format with hours from 1 to 12, the minutes and an AM or PM marker. This conversion works like follows: • 0 hours become 12 o’oclock AM, • 1 through 11 hours become 1 through 11 hours AM, • 12 hours become 12 o’clock PM, • 13 through 23 hours become 1 through 11 hours PM, with a subtraction of 12. The program then displays the time in the usual US format. Please use care when displaying the minutes, as an extra zero needs to be displayed for minutes 0 to 9. See the examples below for details. Examples of input and output: Please enter the hours on a 24 hour clock (0-23): 15 Please enter the minutes (0-59): 7 You entered 3:07PM Please enter the hours on a 24 hour clock (0-23): 27 Please enter the minutes (0-59): 17 Sorry, your input is incorrect. Write a program clock.c that asks the user to input a moment in time as an hour and a minute. The hours are given in a 24 hour (European/Military) format, with hours from 0 to 23. The minutes are given as usual, between 0 and 59.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Control Structure
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++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
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