Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How do I do this? In this exercise, you will create a program that displays a me

ID: 3936473 • Letter: H

Question


How do I do this?

In this exercise, you will create a program that displays a measurement in either inches or centimeters. If necessary, create a new project named Introductory!? Project, and save it in the Cpp8 Chap 10 folder. The program should allow the user the choice of converting a measurement from inches to centimeters or vice versa. Use two void functions: one for each different conversion type. Enter your C++ instructions into a source file named Introductoryl7.cpp. Also enter appropriate comments and any additional instructions required by the compiler. Test the application appropriately.

Explanation / Answer

#include <iostream>

using namespace std;

//function to convert Inches To Centeimeters
void convertInchesToCMs(double inches,double *result)
{
*result=inches * 2.54;
}
//function to convert Centeimeters To Inches
void convertCMsToInches(double centmeters,double *result)
{
*result=centmeters / 2.54;
}
int main()
{
//declaration
int choice;
double result;
double inches;
double centmeters;

//prompt for choice
cout<<" MENU 1. Convert inches to centimeters 2. Convert centimeters to inches ";
cout<<"Enter your choice:";
cin>>choice;

//case to choose
switch(choice)
{
case 1:
{
cout<<"Enter inches:";
cin>>inches;
convertInchesToCMs(inches,&result);
cout<<"Result in CM:"<<result<<endl;
}
break;
case 2:
{
cout<<"Enter inches:";
cin>>centmeters;
convertCMsToInches(centmeters,&result);
cout<<"Result in Inches:"<<result<<endl;
}
break;
default:
cout<<"Invalid choice "<<endl;
}

return 0;
}

OUTPUT:

MENU
1. Convert inches to centimeters
2. Convert centimeters to inches
Enter your choice:1
Enter inches:2
Result in CM:5.08

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote