Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<conio.h>
- #include<iostream.h>
- class dm;
- class db;
- class dm
- {
- float met,cmet;
- public:
- dm()
- {
- cout<<"\n Class DM\n";
- cout<<"Enter the Meter : " ;
- cin>>met;
- cout<<"\nEnter the Centemeter: ";
- cin>>cmet;
- }
- friend void sum(dm,db);
- };
- class db
- {
- float foot,inch;
- public:
- db()
- {
- cout<<"\n Class Db\n";
- cout<<"Enter the FOOT : " ;
- cin>>foot;
- cout<<"\nEnter the INCH : ";
- cin>>inch;
- }
- friend void sum(dm,db);
- };
- void sum(dm d1 , db b1)
- {
- clrscr();
- int ch;
- cout<<"\nMETER => "<<d1.met<< " Centemeter => "<<d1.cmet;
- cout<<"\nFOOT => "<<b1.foot<< " Inch => "<<b1.inch;
- cout<<"\n CHOICE";
- cout<<"\n1. you want ans in inch and Foot";
- cout<<"\n2. you want ans in centemeter and meter";
- cout<<"\nEnter your choice : ";
- cin>>ch;
- switch(ch)
- {
- case 1: //turn meter and centemeter in to foot and inch;
- while(d1.cmet>100)
- {
- d1.met++;
- d1.cmet=d1.cmet-100;
- }
- cout<<"\n METER=> "<<d1.met;
- cout<<"\n CENTEMETER=> "<<d1.cmet;
- //converting meter in to foot
- d1.met=d1.met*3.281;
- //converting centemeter in to inch
- d1.cmet=d1.cmet/2.54 ;
- cout<<"\n Class DM's convertion met in to foot and centemeter in to inch\n";
- cout<<"\n FOOT=> "<<d1.met;
- cout<<"\n INCH=> "<<d1.cmet;
- cout<<"\n Class Db's FOOT and INCH\n";
- cout<<"\nFOOT => "<<b1.foot<< "\n Inch => "<<b1.inch;
- cout<< "\n\n=====SUM of those are:======\n";
- while((d1.cmet+b1.inch)>12)
- {
- b1.foot++;
- b1.inch=b1.inch-12;
- }
- cout<<"\nTotal FOOT=> "<<d1.met+b1.foot;
- cout<<"\nTotal INCH=> "<<d1.cmet+b1.inch;
- break;
- case 2:
- while(b1.inch>12)
- {
- b1.foot++;
- b1.inch=b1.inch-12;
- }
- cout<<"\n FOOT=> "<<b1.foot;
- cout<<"\n INCH=> "<<b1.inch;
- //converting foot in to meter
- b1.foot=b1.foot/3.281;
- //converting inch in to centemeter
- b1.inch=b1.inch*2.54 ;
- cout<<"\n Class DB's convertion foot in to meter and inch in to centemeter\n";
- cout<<"\nMETER => "<<b1.foot<< "\n centemeter => "<<b1.inch;
- cout<< "\n Class dm 's meter and centemeter ";
- cout<<"\n Meter => "<<d1.met;
- cout<<"\n Centemeter => "<<d1.cmet;
- cout<< "\n\n=====SUM of those are:======\n";
- while((d1.cmet+b1.inch)>100)
- {
- b1.foot++;
- b1.inch=b1.inch-100;
- }
- cout<<"\nTotal FOOT=> "<<d1.met+b1.foot;
- cout<<"\nTotal INCH=> "<<d1.cmet+b1.inch;
- break;
- default:
- cout<<"\n Wrong input";
- cout<<"\n Enter a key to rechoice:";
- cin>>ch;
- sum( d1, b1);
- break;
- }
- }
- int main()
- {
- clrscr();
- dm d1;
- db b1;
- sum( d1, b1);
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement