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

Create four functions; (A) inches to centimeters, (B) centimeters to inches, (C)

ID: 3682548 • Letter: C

Question

Create four functions; (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. 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 points)

2. Printout of your C++ program with a heading comment, also appropriate spacing

and indentation in the program body. You must use four functions and those

functions must be called from the main program in order to receive any credit.

(6 points)

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. (2 points)

/*

ELEN 1301-48F Programming Assignment #9.

Name : Your name.

Student ID : Your student ID #.

Due date :

Purpose of the program :

Create a menu driven program with functions that converts inches to

centimeters, centimeters to inches, feet and inches to meters and meters

to feet and inches.

Section 1 : Show a menu.

Section 2 : Perform the conversion according to the user’s choice.

Section 3 : Repeat section 1 and 2 until an user enters “E” or “e” for

exit the program.

*/

// Write your own program.

Output example:

Please select a conversion function to be performed:

A / a : inches to centimeters.

B / b : centimeters to inches.

C / c : feet and inches to meters.

D / d : meters to feet and inches.

E / e : exit the program.

Please enter your command : a

Please enter inches : 11

11 inches = 27.94 cm.

Please select a conversion function to be performed:

A / a : inches to centimeters.

B / b : centimeters to inches.

C / c : feet and inches to meters.

D / d : meters to feet and inches.

E / e : exit the program.

Please enter your command : b

Please enter cm : 11

11 cm = 4.33071 inches.

Please select a conversion function to be performed:

A / a : inches to centimeters.

B / b : centimeters to inches.

C / c : feet and inches to meters.

D / d : meters to feet and inches.

E / e : exit the program.

Please enter your command : C

Please enter feet : 11

Please enter inches : 11

11 feet and 11 inches = 3.6322 meters.

Please select a conversion function to be performed:

A / a : inches to centimeters.

B / b : centimeters to inches.

C / c : feet and inches to meters.

D / d : meters to feet and inches.

E / e : exit the program.

Please enter your command : D

Please enter meters : 11

11 meters = 36 feet and 1.07087 inches.

Please select a conversion function to be performed:

A / a : inches to centimeters.

B / b : centimeters to inches.

C / c : feet and inches to meters.

D / d : meters to feet and inches.

E / e : exit the program.

Please enter your command : f

You entered invalid choice.

Please select a conversion function to be performed:

A / a : inches to centimeters.

B / b : centimeters to inches.

C / c : feet and inches to meters.

D / d : meters to feet and inches.

E / e : exit the program.

Please enter your command : E

Program terminates. Good bye.

Press any key to continue . . .

Explanation / Answer

#include<iostream>
#include<conio.h>
#include<math.h>
using namespace std;

void inches_to_centimeters();
void centimeters_to_inches();
void main()
{
char choice;
   cout<<"Please select the conversion to be performed ";
   cout<<"A/a:inches to centimeters ";
   cout<<"B/b:centimeters to inches ";
  
   cout<<"E/e:Exit the program ";
   cout<<"Please enter your command ";
   cin>>choice;
   switch (choice)
   {
   case 'A': inches_to_centimeters();
       break;
   case 'a': inches_to_centimeters();
       break;
   case 'B': centimeters_to_inches();
               break;
   case 'b': centimeters_to_inches();
               break;
  
              
   case 'E': exit(0);
               break;
   case 'e': exit(0);
               break;
   default: "you entered invalid choice ";
   }      
getch();

}


void inches_to_centimeters()
   {
       float inch,centimeter;
       cout<<"please enter inches :";
       cin>>inch;
       centimeter = (2.54 * inch);
       cout<< inch <<"inches = " <<centimeter <<"centimeters"<<endl;
       //return 0;
}


void centimeters_to_inches()
   {
       float inch,centimeter;
       cout<<"please enter cm :";
       cin>>centimeter;
       inch = (0.393701 * centimeter);
       cout<< centimeter <<"cm = " <<inch <<"inches"<<endl;
  
}

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