Sie sind auf Seite 1von 4

/*EXPERIMENT NO:2

Name:atharv karanjkar
Div:j
Branch:AI&DS
URN:21091040
*/

#include<iostream.h>
#include<conio.h>

class geometry
{
private:
int l,b,h,r,a,vl,ar;

public:
void area(float l,float b,float h)
{
ar=2*(l*b+b*h+l*h);
cout<<"Area of cuboid:"<<ar<<" sq.unit"<<endl;
}
void area(float a)
{
ar=6*a*a;
cout<<"Area of cube:"<<ar<<" sq.unit"<<endl;
}
void area(float r,float h)
{
float pi=3.14;
ar=2*pi*r*h+2*pi*r*r*r;
cout<<"Area of cylinder:"<<ar<<" sq.unit"<<endl;
}
void vol(float l,float b,float h)
{
vl=l*b*h;
cout<<"Volm of cuboid:"<<vl<<" sq.unit"<<endl;
}
void vol(float a)
{
vl=a*a*a;
cout<<"Volm of cube:"<<vl<<" cb.unit"<<endl;
}
void vol(float r,float h)
{
float pi=3.14;
vl=pi*r*r*h;
cout<<"Volm of cylinder:"<<vl<<" sq.unit"<<endl;
}
};
void main()
{
geometry g;
int choice,i=10;
clrscr();
while(1)
{
cout<<"\n LET'S FIND VOLUME AND SURFACE AREA
OF SHAPES..."<<endl;
cout<<"\n1.CUBOID\n2.CUBE\n3.CYLINDER\n4.EXIT"<<endl;
cout<<"\nCHOOSE THE SHAPE"<<endl;
cin>>choice;

if(choice==4)
break;
switch(choice)
{
case 1:
int l,b,h;
cout<<"\nENTER l,b,h of CUBOID:"<<endl;
cin>>l>>b>>h;
g.area(l,b,h);
g.vol(l,b,h);
break;
case 2:
int a;
cout<<"\nENTER side of CUBE:"<<endl;
cin>>a;
g.area(a);
g.vol(a);
break;
case 3:
int r;
cout<<"\nENTER the raddi and hight of
CUBE:"<<endl;
cin>>r>>h;
g.area(r);
g.vol(r);
break;
default:
cout<<"\nWRONG CHOICE"<<endl;
}
}

getch ();
}

output :

Das könnte Ihnen auch gefallen