Already have an account? Get multiple benefits of using own account!
Login in your account..!
Remember me
Don't have an account? Create your account in less than a minutes,
Forgot password? how can I recover my password now!
Enter right registered email to receive password!
Aim: To implement a program to convert distance given in feet and inches into meters and centimeters and vice versa.
Code:
class mcm;
class inchft
{
float ft;
float inch;
public:
friend void convert(inchft,mcm);
};
class mcm
float m;
float cm;
void convert(inchft a,mcm b)
int ch,i,c;
do
cout<<"\n1.Feet & inches to Meters & centimeters";
cout<<"\n2. Meters & Centimeters to Feet & inches";
cout<<"\n0. Exit\nEnter choice:";
cin>>ch;
switch(ch)
case 1:
cout<<"Enter measurement in feet & inches:";
cout<<"ft:";
cin>>a.ft;
cout<<"inch:";
cin>>a.inch;
cout<<"\nYou entered:"< i=(a.inch+(12.0*a.ft)); c=2.5*i; c=ceil(c); b.cm=c%100; b.m=(c-b.cm)/100; cout<<"\n\nAfter conversion:"< break; case 2: cout<<"Enter measurement in meters & centimeters:"; cout<<"m:"; cin>>b.m; cout<<"cm:"; cin>>b.cm; cout<<"\nYou entered:"< c=(b.cm+(100*b.m)); i=0.4*c; i=ceil(i); a.inch=i%12; a.ft=(i-a.inch)/12; cout<<"\n\nAfter conversion:"< break; case 0: break; } }while(ch!=0); } void main() { clrscr(); inchft a; mcm b; convert(a,b); getch(); } Output: 1.Feet & inches to Meters & centimeters 2. Meters & Centimeters to Feet & inches 0. Exit Enter choice:1 Enter measurement in feet & inches:ft:20 inch:10 You entered:20 ft 10 inches After conversion:6 m 25 cm 1.Feet & inches to Meters & centimeters 2. Meters & Centimeters to Feet & inches 0. Exit Enter choice:2 Enter measurement in meters & centimeters:m:6 cm:25 You entered:6 m 25 cm After conversion:20 ft 10 inches 1.Feet & inches to Meters & centimeters 2. Meters & Centimeters to Feet & inches 0. Exit Enter choice:0
i=(a.inch+(12.0*a.ft));
c=2.5*i;
c=ceil(c);
b.cm=c%100;
b.m=(c-b.cm)/100;
cout<<"\n\nAfter conversion:"< break; case 2: cout<<"Enter measurement in meters & centimeters:"; cout<<"m:"; cin>>b.m; cout<<"cm:"; cin>>b.cm; cout<<"\nYou entered:"< c=(b.cm+(100*b.m)); i=0.4*c; i=ceil(i); a.inch=i%12; a.ft=(i-a.inch)/12; cout<<"\n\nAfter conversion:"< break; case 0: break; } }while(ch!=0); } void main() { clrscr(); inchft a; mcm b; convert(a,b); getch(); } Output: 1.Feet & inches to Meters & centimeters 2. Meters & Centimeters to Feet & inches 0. Exit Enter choice:1 Enter measurement in feet & inches:ft:20 inch:10 You entered:20 ft 10 inches After conversion:6 m 25 cm 1.Feet & inches to Meters & centimeters 2. Meters & Centimeters to Feet & inches 0. Exit Enter choice:2 Enter measurement in meters & centimeters:m:6 cm:25 You entered:6 m 25 cm After conversion:20 ft 10 inches 1.Feet & inches to Meters & centimeters 2. Meters & Centimeters to Feet & inches 0. Exit Enter choice:0
break;
case 2:
cout<<"Enter measurement in meters & centimeters:";
cout<<"m:";
cin>>b.m;
cout<<"cm:";
cin>>b.cm;
cout<<"\nYou entered:"< c=(b.cm+(100*b.m)); i=0.4*c; i=ceil(i); a.inch=i%12; a.ft=(i-a.inch)/12; cout<<"\n\nAfter conversion:"< break; case 0: break; } }while(ch!=0); } void main() { clrscr(); inchft a; mcm b; convert(a,b); getch(); } Output: 1.Feet & inches to Meters & centimeters 2. Meters & Centimeters to Feet & inches 0. Exit Enter choice:1 Enter measurement in feet & inches:ft:20 inch:10 You entered:20 ft 10 inches After conversion:6 m 25 cm 1.Feet & inches to Meters & centimeters 2. Meters & Centimeters to Feet & inches 0. Exit Enter choice:2 Enter measurement in meters & centimeters:m:6 cm:25 You entered:6 m 25 cm After conversion:20 ft 10 inches 1.Feet & inches to Meters & centimeters 2. Meters & Centimeters to Feet & inches 0. Exit Enter choice:0
c=(b.cm+(100*b.m));
i=0.4*c;
i=ceil(i);
a.inch=i%12;
a.ft=(i-a.inch)/12;
cout<<"\n\nAfter conversion:"< break; case 0: break; } }while(ch!=0); } void main() { clrscr(); inchft a; mcm b; convert(a,b); getch(); } Output: 1.Feet & inches to Meters & centimeters 2. Meters & Centimeters to Feet & inches 0. Exit Enter choice:1 Enter measurement in feet & inches:ft:20 inch:10 You entered:20 ft 10 inches After conversion:6 m 25 cm 1.Feet & inches to Meters & centimeters 2. Meters & Centimeters to Feet & inches 0. Exit Enter choice:2 Enter measurement in meters & centimeters:m:6 cm:25 You entered:6 m 25 cm After conversion:20 ft 10 inches 1.Feet & inches to Meters & centimeters 2. Meters & Centimeters to Feet & inches 0. Exit Enter choice:0
case 0:
}
}while(ch!=0);
void main()
clrscr();
inchft a;
mcm b;
convert(a,b);
getch();
Output:
1.Feet & inches to Meters & centimeters
2. Meters & Centimeters to Feet & inches
0. Exit
Enter choice:1
Enter measurement in feet & inches:ft:20
inch:10
You entered:20 ft 10 inches
After conversion:6 m 25 cm
Enter choice:2
Enter measurement in meters & centimeters:m:6
cm:25
You entered:6 m 25 cm
After conversion:20 ft 10 inches
Enter choice:0
Explain the Symbolic Constants in c language? Symbolic constants are the constants of any type that declared by using the #define compiler directive and it is a preprocessor di
#questionHi, I am looking for help with the assignment, can you help..
What are P r im a r y D a t a T y p es? Integer can be defined according to the size of the data and it can be modified further by using keyword unsigned and si
A string is said to be "Beautiful"€, if it contains only non repetitive alphabets
Railway station simulation codeing in c..
#questionAt a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets
C Program for FUNCTION OF COMPOUND INTEREST float ci(float,float,float); void main() { float p=0,r=0,n=0,k=0; clrscr(); printf("EN
Define Generic Bitwise Operations? Bitwise operators only work on an incomplete number of types int and char. It turns out there's above one kind of int. In particular there's
Illustration of Plot function: To be more common, the script could prompt the user for the time and temperature, instead of just assigning the values. Then, the axis function
Explain Operator Overloading It is one type of Polymorphism, an significant feature of object-oriented programming .Polymorphism means one thing having many forms, i.e. here an
Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!
whatsapp: +1-415-670-9521
Phone: +1-415-670-9521
Email: [email protected]
All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd