0% found this document useful (0 votes)
61 views5 pages

Project - Shape Mensuration

The document defines classes for calculating areas and perimeters of 2D shapes like square, rectangle, circle, rhombus and trapezium. It also defines classes for 3D shapes like cube, cuboid, sphere, cylinder and cone to calculate their volumes, total surface areas and lateral surface areas.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views5 pages

Project - Shape Mensuration

The document defines classes for calculating areas and perimeters of 2D shapes like square, rectangle, circle, rhombus and trapezium. It also defines classes for 3D shapes like cube, cuboid, sphere, cylinder and cone to calculate their volumes, total surface areas and lateral surface areas.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

import java.util.

*;
public class MAIN
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("1. 2D SHAPE"+"\n2. 3D SHAPE");
System.out.println("Enter Choice Of Shape");
int schoice=sc.nextInt();
switch(schoice)
{
case 1:
System.out.println("1.Square");
System.out.println("2.Rectangle");
System.out.println("3.Circle");
System.out.println("4.Rhombus");
System.out.println("5.Trapezium");
System.out.println("Select Shape");
int choice=sc.nextInt();
switch(choice)
{
case 1:
square s1=new square();
s1.area();
s1.peri();
break;
case 2:
rectangle r1=new rectangle();
r1.area();
r1.peri();
break;
case 3:
circle c1=new circle();
c1.area();
c1.peri();
break;
case 4:
rhombus r2=new rhombus();
r2.area();
r2.peri();
break;
case 5:
trapezium t1=new trapezium();
t1.area();
t1.peri();
break;
}
break;
case 2:
System.out.println("1. Cube");
System.out.println("2. Cuboid");
System.out.println("3. Sphere");
System.out.println("4. Cylinder");
System.out.println("5. Cone");
System.out.println("Select Shape");
int fchoice=sc.nextInt();
switch(fchoice)
{
case 1:
cube c2=new cube();
c2.volume();
c2.sa();
c2.la();
break;
case 2:
cuboid c3=new cuboid();
c3.volume();
c3.sa();
c3.la();
break;
case 3:
sphere s1=new sphere();
s1.volume();
s1.sa();
s1.la();
break;
case 4:
cylinder c4=new cylinder();
c4.volume();
c4.sa();
c4.la();
break;
case 5:
cone c5=new cone();
c5.volume();
c5.sa();
c5.la();
break;

}
break;
default :
System.out.println("Wrong choice");
break;
}
}
}
class square
{
int side=5,a=0,p;
void area()
{
a=side*side;
System.out.println("Area of Square "+a);
}
void peri()
{
p=4*side;
System.out.println("Perimeter of Square "+p);
}
}
class rectangle
{
int l=2,b=5,a,p;
void area()
{
a=l*b;
System.out.println("Area of Rectangle "+a);
}
void peri()
{
p=2*(l+b);
System.out.println("Perimeter of Rectangle "+p);
}

}
class circle
{
double r=3.0,a,c;
void area()
{
a=3.14*r*r;
System.out.println("Area of Circle "+a);
}
void peri()
{
c=2*3.14*r;
System.out.println("Circumference of Circle "+c);
}
}
class rhombus
{
double d1=4.0,d2=6.0,side=4,a,p;
void area()
{
a=0.5*d1*d2;
System.out.println("Area of Rhombus "+a);
}
void peri()
{
p=4*side;
System.out.println("Perimeter of Rhombus "+p);
}
}
class trapezium
{
double h=2.0,a=3.0,b=4.0,c=6.0,d=4.0,a1,p;
void area()
{
a1=0.5*h*(a+c);
System.out.println("Area of Trapezium "+a1);
}
void peri()
{
p=a+b+c+d;
System.out.println("Perimeter of Trapezium "+p);
}
}
class cube
{
int a=3,tsa,lsa,v;
void volume()
{
v=a*a*a;
System.out.println("Volume of Cube "+v);
}
void sa()
{
tsa=6*a*a;
System.out.println("Total Surface Area of Cube "+tsa);
}
void la()
{
lsa=4*a*a;
System.out.println("Lateral Surface Area "+lsa);
}
}
class cuboid
{
int l=6,b=3,h=4,v,lsa,tsa;
void volume()
{
v=l*b*h;
System.out.println("Volume of Cuboid "+v);
}
void sa()
{
tsa=2*(l*b+b*h+h*l);
System.out.println("Total Surface Area "+tsa);
}
void la()
{
lsa=2*h*(l+b);
System.out.println("Lateral Surface Area "+lsa);
}
}
class sphere
{
double r=6;
double v,lsa,tsa;
void volume()
{
v=4/3*3.14*r*r*r;
System.out.println("Volume of Sphere "+v);
}
void sa()
{
tsa=4*3.14*r*r;
System.out.println("Total Surface Area "+tsa);
}
void la()
{
lsa=4*3.14*r*r;
System.out.println("Lateral Surface Area "+lsa);
}
}
class cylinder
{
double r=3,h=8,v,lsa,tsa;
void volume()
{
v=3.14*r*r*h;
System.out.println("Volume of Cylinder "+v);
}
void sa()
{
tsa=2*3.14*r*h+2*3.14*r*r;
System.out.println("Total Surface Area "+tsa);
}
void la()
{
lsa=2*3.14*r*h;
System.out.println("Lateral Surface Area "+lsa);
}
}
class cone
{
double r=3,h=6,l=6,v,tsa,lsa;
void volume()
{
v=(3.14*r*r*h)/3;
System.out.println("Volume of Cone "+v);
}
void sa()
{
tsa=3.14*r*(r+l);
System.out.println("Total Surface Area "+tsa);
}
void la()
{
lsa=3.14*r*l;
System.out.println("Lateral Surface Area "+lsa);
}
}

You might also like