Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // aSSIGNMENT OOP P1
- // OVERLOADING FUNCTIONS;
- #include<iostream>
- using namespace std;
- class area
- {
- public:
- void draw(double l,double h)//area of rectangle
- {
- cout<<"\nRECTANGLE=======================";
- double ans;
- ans=l*h;
- cout<<"\n Area of rectangle => "<<ans;
- }
- void draw(double r)//area of circle
- {
- double ans;
- ans=r*r*3.14;
- cout<<"\n Area of circle => "<<ans;
- }
- void draw(double h, float b)//area of triangle
- {
- float ans;
- ans=(b*h)/2;
- cout<<"\n Area of triangle => "<<ans;
- }
- };
- int main()
- {
- area a1;
- int ch;
- double h1,r,l,h;
- float b;
- do
- {
- cout<<"\n Menu of area";
- cout<<"\n 1.rectangle";
- cout<<"\n 2.circle";
- cout<<"\n 3.triangle";
- cout<<"\n 4.Exit(*L*)";
- cout<<"\n Enter your choice: ";
- cin>>ch;
- switch(ch)
- {
- case 1:
- cout<<"\n\t\t===== Rectangle =====";
- cout<<endl<<"Enter the height : ";
- cin>>h1;
- cout<<endl<<"Enter the Length : ";
- cin>>l;
- a1.draw(l,h1);
- break;
- case 2:
- cout<<"\n\t\t===== Circle =======";
- cout<<endl<<"Enter the rediuse : ";
- cin>>r;
- a1.draw(r);
- break;
- case 3:
- cout<<"\n\t\t===== Triangle ======";
- cout<<endl<<"Enter the height : ";
- cin>>h;
- cout<<endl<<"Enter the base : ";
- cin>>b;
- a1.draw(h,b);
- break;
- }
- }while(ch>=1 && ch<=3);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement