C program to change feet and inches into meter, C/C++ Programming

Assignment Help:

 

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;

            public:

            friend void convert(inchft,mcm);

};

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


Related Discussions:- C program to change feet and inches into meter

Explain the changing field width, Changing Field width The printf() and...

Changing Field width The printf() and scanf() functions from the standard library, use width specifier for controlling the width of its output . Similarly, the ostream class al

C++ programming, Write a program to convert English units to metric (e.g., ...

Write a program to convert English units to metric (e.g., miles to kilometers, gallons to liters, etc.). Include a specification and a code design.

Write a program for simulating jet-powered car acceleration, The absolute l...

The absolute land-speed record of 763.035 MPH (Mach 1.02) was set in October 15 1997 by a jet-powered car called Thrust SSC in the Black Rock Desert of northern Nevada. The team th

Describe difference between malloc()/free() & new/delete?, for object, mall...

for object, malloc allocates memory in heap however doesn't invoke object's constructor to initialize the object. new allocates memory & also invokes constructor to initialize the

Area under curve, progarm in c for area under curve   #include ...

progarm in c for area under curve   #include float start_point, /* GLOBAL VARIABLES */ end_point, total_area; int numtraps;

How the operations are performed in a single linked list, Question: (a)...

Question: (a) Explain a linked list. (b) Describe the three different types of linked list with the help of diagrams. (c) Give two advantages and two disadvantages

#change to palidrome program, #A palindrome is a string that reads the same...

#A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrom

Need epos programmng and building, Project Description: I have a barber ...

Project Description: I have a barber salon I am seeking someone to build me software for my PARTNER PT6910 touch screen till system. This software must add multiple staff login

Question, wap to calculatethe volume of cone,cylinderand sphere

wap to calculatethe volume of cone,cylinderand sphere

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

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!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd