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 1PE
Program Plan Intro

Implementation of a program to convert the feet and inches to centimeters.

Program Plan:

Write a C++ program with a main function and the required set of statements to accomplish the following:

Prompts the user to enter feet and inches.

Check if the feet or inches are less than 0 then throw an exception.

Check if the user enters values other than integer then throw an exception.

Otherwise get the values for feet and inches and print the output in centimeters.

Blurred answer
Students have asked these similar questions
Write a program that prompts the user to enter a length in feet and then enter a length in inches and outputs the equivalent length in centimeters. If the user enters a negative number or a non-digit number, throw and handle an appropriate exception and prompt the user to enter another set of numbers. Your error message should read A non positive number is entered and allow the user to try again. Format your output with setprecision(2) to ensure the proper number of decimals for testing!
Write a program using c++ oop that prompts the user to enter a length in feet and inches and outputs the equivalent length in centimeters. If the user enters a negative number, throw and handle an appropriate exception and prompt the user to enter another set of numbers.
Write a program that converts a time from 24-hour notation to 12-hour notation. To make the solution easier, a requirement is imposed on the input: It must be in xx:xx format, i.e. it must have two digits, a colon, and then another two digits. Define an exception class called TimeException. If the user enters an illegal time, like 10:65, or even gibberish, like 8&*68, your program should throw and handle a TimeException. Test your program with the file "times.txt" as input and store the result in the file "result.txt"   File times.txt: 00:00 12:00 12:01 11:59 23:59 24:00 10:65 3:23 1145 8&*68   File result.txt: #         24-hour           12-hour -------------------------------------------- 1          00:00               12:00 AM 2          12:00               12:00 PM 3          12:01                12:01 PM 4          11:59                11:59 AM 5          23:59               11:59 PM 6          24:00               Time Exception 7          10:65…

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