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

In this exercise, you will create a program that displays a measurement in eithe

ID: 3936404 • Letter: I

Question

In this exercise, you will create a program that displays a measurement in either inches

or centimeters. If necessary, create a new project named Introductory17 Project, and

save it in the Cpp8Chap10 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 Introductory17.cpp. Also, enter appropriate comments and any additional

instructions required by the compiler. Test the application appropriately.

In this exercise, you will create a program that displays a measurement in either inches

or centimeters. If necessary, create a new project named Introductory17 Project, and

save it in the Cpp8Chap10 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 Introductory17.cpp. Also, enter appropriate comments and any additional

instructions required by the compiler. Test the application appropriately.

Explanation / Answer

#include <iostream>
#include <iomanip>
using namespace std;

void cmstoinches()
{
   double cms,inches;
   cout<<" Enter centimetres";
       cin>>cms;
      
       inches = cms/2.54; //cms to inches conversion
      
   cout<<" "<<cms<<" centimetres = ";
   cout<< setprecision(2) << fixed<<inches<<" inches";
}

void inchestocms()
{
   double inches,cms;
   cout<<" Enter inches";
       cin>>inches;
      
       cms = inches*2.54;
      
       cout<<" "<<inches<<" inches = ";
       cout<<setprecision(2) << fixed<<cms<<" centimetres";
      
}
  

int main()
{
   int choice;
   double cms,inches;
   cout<<" Enter 1 to convert inches to centimetres and 2 to convert centimetres to inches";
   cin>>choice;
  
   if(choice == 1) //inches to cms conversion
   {
   inchestocms();  
   }
   else if(choice == 2)
   {
   cmstoinches();      
      
   }
  
  
  
   return 0;
}

output:

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