Question: This program will combine the functionality of the previous 2 programs. It will: Ask the user if he or she wants to convert from feet

This program will combine the functionality of the previous 2 programs. It will:
Ask the user if he or she wants to convert from feet and inches to meters or from meters to feet and inches.
The user responds by entering 1 to convert from feet and inches or 2 to convert from meters.
Your program will read the users selection and then execute an if else statement to where each branch will contain a call to an appropriate function which will then drive the rest of the application based on that selection.
You must use the following definition of main. The only modification to main should be the addition of the code to insure the user enters either 1 or 2 for the choice of conversion. You will build the rest of your program using the functions that you created in problems 2 and 3.
int main()
{
char ans; //loop control variable
int which; //stores the choice of conversion
do
{
//Add a loop here to insure that the user enters either 1 or 2
cout <<"
Enter 1 for English to Metric or "<< endl
<< "Enter 2 for Metric to English conversion"
<< endl;
cin >> which;
if (1== which)
ConvertToMetric();//calls the ConvertToMetric functions
else
ConvertToEnglish();//calss the ConvertToEnglish functions
cout <<"Y or y allows another choice of conversion. "
<< "any other quits" << endl;
cin >> ans;
} while ('y'== ans ||'Y'== ans);
return 0;
}
Test with the following data:
feet inches
6
4
meters
20.05
100.5
Your test run should mirror the test run on the next page.
Test Run
Enter 1 for English to Metric or
Enter 2 for Metric to English conversion
1
Enter feet as an integer: -300
Enter inches as a double: 200
Invalid data - please re-enter
Enter feet as an integer: 500
Enter inches as a double: 6
152.55 meters corresponds to 500 feet, 6.00 inches
Y or y allows another choice of conversion. any other quits
y
Enter 1 for English to Metric or
Enter 2 for Metric to English conversion
1
Enter feet as an integer: 501
Enter inches as a double: 4
152.81 meters corresponds to 501 feet, 4.00 inches
Y or y allows another choice of conversion. any other quits
y
Enter 1 for English to Metric or
Enter 2 for Metric to English conversion
2
Enter a number of meters as a double
-50
Invalid data - please re-enter
Enter a number of meters as a double
20.05
20.05 meters corresponds to 65 feet, 9.37 inches
Y or y allows another choice of conversion. any other quits
y
Enter 1 for English to Metric or
Enter 2 for Metric to English conversion
2
Enter a number of meters as a double
100.50
100.50 meters corresponds to 329 feet, 8.69 inches
Y or y allows another choice of conversion. any other quits
n

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!