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

Create a menu driven C++ program that converts (A) inches to centimeters, (B) ce

ID: 3682822 • Letter: C

Question

Create a menu driven C++ program that converts (A) inches to centimeters, (B) centimeters to inches, (C) feet and inches to meters, (D) meters to feet and inches and (E) exit the program. *******PLEASE USE A LOOP AND A SWITCH / CASE STATEMENT ******** Your program must accommodate both upper and lower cases for the choice and produce an error message when an invalid choice is made. Please Submit: 1. A flowchart of your program. 2. Printout of your C++ program with a heading comment, also appropriate spacing and indentation in the program body. You must use a loop and a switch / case statements 3. Copy of a screenshot after your program is executed. Test your program with both upper case and lower case selection. (Ex: a, b, C, D, f, and E) Use the last number of your student ID + 2 for all input.

Explanation / Answer

include <iostream>

#include <math.h>

using namespace std;

int main()
{
//declaration of variables

char o;

double inches, centimeters,feet,meter;

//runs until press e or E

while(true)

{

cout<<"Please select conversion method to be performed ";
cout << " A/a inches to centimeters ";

cout << "B/b centimeters to inches ";
cout << " C/c feet and inches to meters ";
cout << "D/d meters to feet and inches ";
cout << "E/e exit the program ";
switch (o) {

        case 'a':

       case 'A':

         {

//for inches to centimeters

                cout << " Enter inches ";

                 cin>>inches;

           centimeters=2.54*inches;

    cout<<inches<<"inches="<< centimeters<<"cms";

}

case 'b':

       case 'B':

         {

//for centimeters to meters

                cout << " Enter centimeters ";

                 cin>> centimeters;

           inches= centimeters/2.54;

    cout<< centimeters <<" centimeters ="<<inches<<"inches";

}

case 'c':

       case 'C':

         {

//for feets and inches to meter

                cout << " Enter feet’s ";

                 cin>> feet;

               cout << " Enter inches ";

                 cin>> inches;

meter= 0.3048*feet+ 0.0254*inches;

cout<< feet <<" feet and "<< inches <<"inches equals to"<<meter<<"meters";

}

case 'd':

       case 'D':

         {

//for meters to feets and inches

                cout << " Enter meters ";

                 cin>> meter;

feet = floor(meter / 0.3048);

meter -= feet * 0.3048;

inches = floor(meter / 0.0254);

cout<< meter<<"meters equals to "<<feet <<" feet and "<< inches <<"inches";

}

case 'e':

       case 'E':

         {

//for terminating

cout<<"Program terminates good bye ";

exit(0);

}

default:

//for invalid choice

cout<<"You entered invalid choice ";

}

}//while


return 0;
}

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