Programming Assigment Create a menu driven C++ program that converts (A) inches
ID: 3680439 • Letter: P
Question
Programming Assigment
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.
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. (4 points)
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. (4 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)
Programming Assignment #8.
Purpose of the program : Create a menu driven program 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.
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. 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. Please enter can 11 11 cm 4.33071 inches. select a conversion function to be performed Please A a inches to centimeters B b centimeters to inches C c feet and inches to meters D d meters to feet and inches exit the program. Please enter your command C Please enter feet 11 Please enter inches 11 11 feet and 11 inches 3 3.6322 meters Please Belect a oonversion function to be performed: A a inches to centimeters B h centimeters to inches C de feat and inches to naters. D d meters to feet and inches it the program PlaasR RntRr your command C Plaasm antar feet 11 Please enter inches 11 11 Fee L 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 fee and inchea to metera. D d meters to feet and inches E e exit the program Please enter your command D Please enter metera 11 11 meters 6 feet and 1.07087 inahes. Please select a oonversion function to be performed: A a inches to aentimeters B b centimeters to inches C o feet and inches to meters D d meters to feet and inaheg. E e exit the program.Explanation / Answer
Please find the code and output below :
#include<iostream>
#include <math.h>
using namespace std;
int main()
{
char choice;
do
{
float ft,in,m,cm;
cout<<"Please select a conversion function to be performed:"<<endl;
cout<<"A/a : inches to centimeters"<<endl;
cout<<"B/b : centimeters to inches"<<endl;
cout<<"C/c : feet and inches to meters"<<endl;
cout<<"D/d : meters to feet and inches"<<endl;
cout<<"E/e : Exit the program"<<endl;
cout<<"Enter your commad"<<endl;
cin>>choice;
if (choice=='A' || choice=='a')
{
cout<<"please enter inches: ";
cin>>in;
cout<<in <<" inches = "<<(2.54*in)<<" cm."<<endl;
cout<<" "<<endl;
}
else if (choice=='B' || choice=='b')
{
cout<<"please enter centimeters: ";
cin>>cm;
cout<<cm <<" centimeters = "<<(0.3937*cm)<<" inches."<<endl;
cout<<" "<<endl;
}
else if (choice=='C' || choice=='c')
{
cout<<"please enter Feet: ";
cin>>ft;
cout<<"please enter Inches: ";
cin>>in;
cout<<ft<<" feet and "<<in<<" inches = "<< ((0.3048*ft)+(0.0254*in)) <<" meters"<<endl;
cout<<" "<<endl;
}
else if (choice=='D' || choice=='d')
{
cout<<"please enter Meters: ";
cin>>m;
double feet=floor(m/0.3048);
double inches=floor(m/39.3701)-feet*12;
cout<<m<<" meters = "<<feet<<" feet and "<<inches<<" inches"<<endl;
cout<<" "<<endl;
}
}
while(choice!='E' || choice !='e');
if(choice=='E' || choice =='e')
cout<<"Program terminates..good bye."<<endl;
}
--------------------------------------
OUTPUT:
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
Enter your commad
B
please enter centimeters: 11
11 centimeters = 4.3307 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
Enter your commad
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
Enter your commad
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.