Advertisement
Aniket_Goku

p3

Sep 15th, 2020 (edited)
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.70 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<iostream.h>
  4. class dm;
  5. class db;
  6. class dm
  7. {
  8.     float met,cmet;
  9.     public:
  10.         dm()
  11.         {
  12.             cout<<"\n Class DM\n";
  13.             cout<<"Enter the  Meter : " ;
  14.             cin>>met;
  15.             cout<<"\nEnter the Centemeter: ";
  16.             cin>>cmet;
  17.         }
  18.     friend void sum(dm,db);
  19.  
  20. };
  21. class db
  22. {
  23.     float foot,inch;
  24.     public:
  25.         db()
  26.         {
  27.             cout<<"\n Class Db\n";
  28.             cout<<"Enter the  FOOT : " ;
  29.             cin>>foot;
  30.             cout<<"\nEnter the INCH : ";
  31.             cin>>inch;
  32.         }
  33.     friend void sum(dm,db);
  34.  
  35. };
  36. void sum(dm d1 , db b1)
  37. {
  38.     clrscr();
  39.     int ch;
  40.     cout<<"\nMETER => "<<d1.met<< " Centemeter => "<<d1.cmet;
  41.     cout<<"\nFOOT  => "<<b1.foot<< " Inch => "<<b1.inch;
  42.         cout<<"\n CHOICE";
  43.         cout<<"\n1. you want ans in inch and Foot";
  44.         cout<<"\n2. you want ans in centemeter and meter";
  45.         cout<<"\nEnter your choice : ";
  46.         cin>>ch;
  47.         switch(ch)
  48.         {
  49.             case 1:  //turn meter and centemeter in to foot and inch;
  50.                 while(d1.cmet>100)
  51.                 {
  52.                     d1.met++;
  53.                     d1.cmet=d1.cmet-100;
  54.                 }
  55.                 cout<<"\n METER=> "<<d1.met;
  56.                 cout<<"\n CENTEMETER=> "<<d1.cmet;
  57.                 //converting meter in to foot
  58.                 d1.met=d1.met*3.281;
  59.                 //converting centemeter in to inch
  60.                 d1.cmet=d1.cmet/2.54 ;
  61.                 cout<<"\n Class DM's convertion met in to foot and centemeter in to inch\n";
  62.                 cout<<"\n FOOT=> "<<d1.met;
  63.                 cout<<"\n INCH=> "<<d1.cmet;
  64.                 cout<<"\n Class Db's FOOT and INCH\n";
  65.                 cout<<"\nFOOT  => "<<b1.foot<< "\n Inch => "<<b1.inch;
  66.                 cout<< "\n\n=====SUM of those are:======\n";
  67.                 while((d1.cmet+b1.inch)>12)
  68.                 {
  69.                     b1.foot++;
  70.                     b1.inch=b1.inch-12;
  71.                 }
  72.                 cout<<"\nTotal FOOT=> "<<d1.met+b1.foot;
  73.                 cout<<"\nTotal INCH=> "<<d1.cmet+b1.inch;
  74.  
  75.             break;
  76.  
  77.             case 2:
  78.                 while(b1.inch>12)
  79.                 {
  80.                     b1.foot++;
  81.                     b1.inch=b1.inch-12;
  82.                 }
  83.                 cout<<"\n FOOT=> "<<b1.foot;
  84.                 cout<<"\n INCH=> "<<b1.inch;
  85.                 //converting foot in to meter
  86.                 b1.foot=b1.foot/3.281;
  87.                 //converting  inch in to centemeter
  88.                 b1.inch=b1.inch*2.54 ;
  89.                 cout<<"\n Class DB's convertion foot in to meter and inch in to centemeter\n";
  90.                 cout<<"\nMETER  => "<<b1.foot<< "\n centemeter => "<<b1.inch;
  91.                 cout<< "\n Class dm 's meter and centemeter ";
  92.                 cout<<"\n Meter => "<<d1.met;
  93.                 cout<<"\n Centemeter => "<<d1.cmet;
  94.  
  95.  
  96.                 cout<< "\n\n=====SUM of those are:======\n";
  97.                 while((d1.cmet+b1.inch)>100)
  98.                 {
  99.                     b1.foot++;
  100.                     b1.inch=b1.inch-100;
  101.                 }
  102.                 cout<<"\nTotal FOOT=> "<<d1.met+b1.foot;
  103.                 cout<<"\nTotal INCH=> "<<d1.cmet+b1.inch;
  104.  
  105.             break;
  106.  
  107.             default:
  108.             cout<<"\n Wrong input";
  109.             cout<<"\n Enter a key to rechoice:";
  110.             cin>>ch;
  111.             sum( d1, b1);
  112.             break;
  113.         }
  114.  
  115. }
  116. int main()
  117. {
  118.     clrscr();
  119.     dm d1;
  120.     db b1;
  121.  
  122.     sum( d1, b1);
  123.     getch();
  124.     return 0;
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement