Problem Solving with C++ (10th Edition)
Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 16, Problem 1PP

Write a program that converts 24-hour time to 12-hour time. The following is a sample dialogue:

Enter time in 24-hour notation:

13:07

That is the same as

1:07 PM

Again?(y/n)

y

Enter time in 24-hour notation:

10:15

That is the same as

10:15 AM

Again?(y/n)

y

Enter time in 24-hour notation:

10:65

There is no such time as 10:65

Try again:

Enter time in 24-hour notation:

16:05

That is the same as

4:05 PM

Again?(y/n)

n

End of program

You will define an exception class called TimeFormatMistake. If the user enters an illegal time, like 10:65 or even gibberish like 8&*68, then your program will throw and catch a TimeFormatMistake.

Blurred answer
Students have asked these similar questions
Write a program that prompts for and reads a double value rep- resenting a monetary amount. Then determine the fewest number of each bill and coin needed to represent that amount, starting with the highest (assume that a 100 zl bill is the maximum size needed).
Use python The speeding ticket fine policy in Wonderland-Bemidji is $50 plus $5 for each mph over the limit, plus an additional penalty of $200 for any speeds over 90mph. Write a program that accepts a speed limit (<= 90) and a clocked speed, and either outputs a message indicating the speed was legal, or prints the amount of the fine if the speed is illegal.
Write a program that reads a number in the input and puts it in rax. Then calculate the sum of odd and even digits and put and print in rbx and rdx, respectively.{rax↦ (rbx, rdx)} Input: An a with the following condition: 1 ≤ a ≤ 3×107 Output Print on a line 2 numbers separated by a space. The first number is the sum of odd digits and the second number is the sum of even digits. Input sample 1 138 Sample output 1 4 8 Input sample 2 777 Sample output 2 21 0

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Background pattern image
Computer Science
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
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Introduction to Operators in C; Author: Neso Academy;https://www.youtube.com/watch?v=50Pb27JoUrw;License: Standard YouTube License, CC-BY