IDNLearn.com: Your one-stop destination for finding reliable answers. Our experts provide prompt and accurate answers to help you make informed decisions on any topic.
Sagot :
Answer:
The program in C++ is as follows:
#include<iostream>
using namespace std;
void in2cm(){
double inch;
cout<<"Inches: "; cin>>inch;
cout<<"Centimeter: "<<2.54 * inch<<endl;}
void ft2cm(){
double feet;
cout<<"Feet: "; cin>>feet;
cout<<"Centimeter: "<<30.48 * feet<<endl;}
void yd2m(){
double yard;
cout<<"Yard: "; cin>>yard;
cout<<"Meter: "<<0.9144 * yard<<endl;}
void mi2km(){
double miles;
cout<<"Mile: "; cin>>miles;
cout<<"Kilometer: "<<1.60934 * miles<<endl;}
void cm2in(){
double cm;
cout<<"Centimeter: "; cin>>cm;
cout<<"Inches: "<<0.393701 * cm<<endl;}
void cm2ft(){
double cm;
cout<<"Centimeter: "; cin>>cm;
cout<<"Feet: "<<0.0328084 * cm<<endl;}
void m2yd(){
double meter;
cout<<"Meter: "; cin>>meter;
cout<<"Yard: "<<1.09361 * meter<<endl;}
void km2mi(){
double km;
cout<<"Kilometer: "; cin>>km;
cout<<"Miles: "<<0.621371 * km<<endl;}
int main(){
cout<<"Menu\n1 - inches to centimeter\n2 - feet to centimeter\n3 - yard to meter\n4 - miles to kilometer";
cout<<"\n5 - centimeter to inches\n6 - centimeter to feet\n7 - meter to yard\n8 - kilometer to miles\n0 - Quit"<<endl;
int menu;
cout<<"Select Menu: "; cin>>menu;
while(menu != 0){
if(menu == 1){ in2cm(); }
else if(menu == 2){ ft2cm(); }
else if(menu == 3){ yd2m(); }
else if(menu == 4){ mi2km(); }
��else if(menu == 5){ cm2in(); }
else if(menu == 6){ cm2ft(); }
else if(menu == 7){ m2yd(); }
else if(menu == 8){ km2mi(); }
else{cout<<"Invalid Menu"<<endl;}
cout<<"Select Menu: "; cin>>menu;
}
return 0;
}
Explanation:
See attachment for complete code where comments are used as explanation
Thank you for using this platform to share and learn. Don't hesitate to keep asking and answering. We value every contribution you make. Thank you for trusting IDNLearn.com. We’re dedicated to providing accurate answers, so visit us again for more solutions.