Answered step by step
Verified Expert Solution
Question
1 Approved Answer
c++ visual studio 2012 Write a program that prompts the user to enter a length in inches and outputs the equivalent length in centimeters. If
c++ visual studio 2012
Write a program that prompts the user to enter a length in 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 number. 1. Program Processing: a. Begin by writing the declaration of a user-defined exception type named NegativeNumber. b. Write a function ConvertTo Centimeters. The function converts the number of inches sent to the function through the parameter list to centimeters (Note: 2.54 centimeters 1 inch) unless the input value is a negative number, in which case a NegativeNumber exception is thrown. Within the main function, write a try-catch statement within a while loop that prompts for and inputs the number of inches (type double) from the keyboard. The try-catch statement calls the ConvertToCentimeters function and outputs the value returned from the function. If a NegativeNumber exception is thrown, print an error message. c
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started