Advertisement
Aniket_Goku

p1

Nov 3rd, 2020
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.41 KB | None | 0 0
  1. // aSSIGNMENT OOP  P1
  2. // OVERLOADING FUNCTIONS;
  3. #include<iostream>
  4. using namespace std;
  5. class area
  6. {
  7.    
  8.     public:
  9.    
  10.     void draw(double l,double h)//area of rectangle
  11.     {
  12.         cout<<"\nRECTANGLE=======================";
  13.         double ans;
  14.         ans=l*h;   
  15.         cout<<"\n Area of rectangle => "<<ans;
  16.     }
  17.     void draw(double r)//area of circle
  18.     {
  19.         double ans;
  20.        
  21.         ans=r*r*3.14;
  22.         cout<<"\n Area of circle => "<<ans;
  23.     }
  24.  
  25.        
  26.     void draw(double h, float b)//area of triangle
  27.     {
  28.         float ans;
  29.         ans=(b*h)/2;
  30.         cout<<"\n Area of triangle => "<<ans;
  31.     }
  32.        
  33. };
  34. int main()
  35. {
  36.     area a1;
  37.     int ch;
  38.     double h1,r,l,h;
  39.     float b;
  40.     do
  41.     {
  42.        
  43.         cout<<"\n Menu of area";
  44.         cout<<"\n 1.rectangle";
  45.         cout<<"\n 2.circle";
  46.         cout<<"\n 3.triangle";
  47.         cout<<"\n 4.Exit(*L*)";
  48.         cout<<"\n Enter your choice: ";
  49.         cin>>ch;
  50.         switch(ch)
  51.         {
  52.             case 1:
  53.                
  54.                 cout<<"\n\t\t===== Rectangle =====";
  55.                 cout<<endl<<"Enter the height : ";
  56.                 cin>>h1;
  57.                 cout<<endl<<"Enter the Length : ";
  58.                 cin>>l;
  59.                 a1.draw(l,h1);             
  60.                
  61.             break;
  62.            
  63.             case 2:
  64.                 cout<<"\n\t\t===== Circle  =======";
  65.                 cout<<endl<<"Enter the rediuse : ";
  66.                 cin>>r;
  67.                 a1.draw(r);
  68.                
  69.             break;
  70.                
  71.             case 3:
  72.                 cout<<"\n\t\t===== Triangle ======";
  73.                 cout<<endl<<"Enter the height : ";
  74.                 cin>>h;
  75.                 cout<<endl<<"Enter the base : ";
  76.                 cin>>b;
  77.                 a1.draw(h,b);
  78.             break;
  79.         }
  80.     }while(ch>=1 && ch<=3);
  81.    
  82.     return 0;
  83. }
  84.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement