C++ Programming: From Problem Analysis to Program Design
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN: 9781337102087
Author: D. S. Malik
Publisher: Cengage Learning
bartleby

Concept explainers

Question
Book Icon
Chapter 14, Problem 4PE
Program Plan Intro

Program Plan:

1. Below mentioned variables are used:

  • input time value entered as input by the user.
  • hr− substring of input and holds the hour value.
  • min- substring of input and holds the Minutes value.
  • sec -substring of input and holds the Seconds value.
  • h−integer variable that holds the value of the hour.
  • m- integer variable that holds the value of minutes.
  • s- integer variable that holds the value of seconds.
  • AorP- integer variable which is 0 when time entered as AM or 1 if it is PM.

2. Below Mentioned functions are used:

  • invalidHr()-the function of class invalidHr which is for throwing invalid hour exception.
  • invalidMin()-the function of class invalidMin which is for throwing invalid minutes exception.
  • invalidSec()-function of class invalidSec which is for throwing invalid seconds exception.
  • main()-main function in the program that reads the input and prints the output.

Program Description:

The program is designed to show the 12 hour format input time in a 24-hour format. The program has three exceptional cases that are for inappropriate hours, minutes, or seconds. Three classes are defined to handle such exceptions.

Blurred answer
Students have asked these similar questions
Write a program that calculates an adult's fat-burning heart rate, which is 70% of 220 minus the person's age. Complete fat_burning_heart_rate() to calculate the fat burning heart rate. The adult's age must be between the ages of 18 and 75 inclusive. If the age entered is not in this range, raise a ValueError exception in get_age() with the message "Invalid age." Handle the exception in __main__ and print the ValueError message along with "Could not calculate heart rate info." Ex: If the input is: 35 the output is: Fat burning heart rate for a 35 year-old: 129.5 bpm If the input is: 17 the output is: Invalid age. Could not calculate heart rate info.
Write a program that calculates an adult's fat-burning heart rate, which is 70% of 220 minus the person's age. Complete fat_burning_heart_rate() to calculate the fat burning heart rate. The adult's age must be between the ages of 18 and 75 inclusive. If the age entered is not in this range, raise a ValueError exception in get_age() with the message "Invalid age." Handle the exception in __main__ and print the ValueError message along with "Could not calculate heart rate info." Ex: If the input is: 35 the output is: Fat burning heart rate for a 35 year-old: 129.5 bpm If the input is: 17 the output is: Invalid age. Could not calculate heart rate info. **This is the output i am having trouble with. on line 20 The print string shows the print(ve, 'could not calculate heart rate info.') And i know that the extra space i see at the begining of that second line of output is due to the comma but I cannot figure out how to make the same line print but with out the space from the comma after…
Write a program that calculates an adult's fat-burning heart rate, which is 70% of 220 minus the person's age. Complete fat_burning_heart_rate() to calculate the fat burning heart rate. The adult's age must be between the ages of 18 and 75 inclusive. If the age entered is not in this range, raise a ValueError exception in get_age() with the message "Invalid age." Handle the exception in_main_ and print the ValueError message along with "Could not calculate heart rate info." Ex: If the input is: 35 the output is: Fat burning heart rate for a 35 year-old: 129.5 bpm If the input is: 17 the output is: Invalid age. Could not calculate heart rate info.

Chapter 14 Solutions

C++ Programming: From Problem Analysis to Program Design

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
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,