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

Area under curve, Write a program to find the area under the curve y = f(x)...

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b.   #include float start_poin

Program, Define a class polynomial with three private data members a, b and...

Define a class polynomial with three private data members a, b and c of type double to represent the coefficient of two degree polynomial(ax^2+bx+c). Include a constructor in a pol

Program to write c++ program, program to write superposition of waves using...

program to write superposition of waves using class and objects

I need decompile library(.dll or .so) into source code, I need Decompile Li...

I need Decompile Library(.DLL or .SO) into source code Project Description: I am seeking an experienced programmer or anyone who knows a thing or two about reverse engineerin

What is the value of a resistor marked as 47kk, (a) Verify the values of th...

(a) Verify the values of the resistors with the following colour coding: (i) red-red-orange-silver (ii) orange-orange-black-blue-green (b) What is the value of a resistor

Amie, what happens when the following command is used? chmod u=rwx,go=r-x f...

what happens when the following command is used? chmod u=rwx,go=r-x foo

Palindrome, A palindrome is a string that reads the same from both the ends...

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 palindrome

C program for function of count the characters in each word, C Program for ...

C Program for FUNCTION OF COUNT THE CHARACTERS IN EACH WORD void count(char c[]); void main() {           char a[50];           int i=0;           clrscr();

Develop a windows application to show computer hardware, - But with less fe...

- But with less features and more user-friendly (particularly for non-tech savvy users). - Software needed having a left menu with links (no pictures required) for every hardwar

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