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!
void covertToCentimeter(int feet, int inches)
{
double centimeters;
centimeters = (((feet+(inches/12.0))*0.3048)*100) - 100;
cout << "Centimeter: " << centimeters;
};
Comments
Leave a comment