Answer to Question #251180 in C++ for HelloWorld

Question #251180

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!


1
Expert's answer
2021-10-14T16:05:02-0400
void covertToCentimeter(int feet, int inches)
{
	double centimeters;
	centimeters = (((feet+(inches/12.0))*0.3048)*100) - 100;
	
	cout << "Centimeter: " << centimeters;
};

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS