# Java program to calculate area of circle rectangle and triangle using switch

Let’s learn java program to calculate area of circle rectangle and triangle using switch.

## Java program to calculate area of circle rectangle and triangle using switch

We can use switch statement to calculate area of circle, rectangle and triangle.

```import java.util.Scanner;
public class FindAreaUsingSwitchStatement
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("1.Area of circle");
System.out.println("2.Area of triangle");
System.out.println("3.Area of rectangle");
System.out.println("Please enter any of the above option: ");
int num = sc.nextInt();
switch(num)
{
System.out.println("Area of circle is: " + areaCircle);
break;
case 2: System.out.println("Please enter base and height of triangle: ");
double base = sc.nextFloat();
double height = sc.nextFloat();
double areaTriangle = (base* height) / 2;
System.out.println("Area of triangle is: " + areaTriangle);
break;
int length = sc.nextInt();
int areaRectangle = length * breadth;
System.out.println("Area of ractangle is: " + areaRectangle);
break;
default:System.exit(0);
}
sc.close();
}
}
```

Output:

1.Area of circle
2.Area of triangle
3.Area of rectangle
Please enter any of the above option: 1
Area of circle is: 78.57142857142857

1.Area of circle
2.Area of triangle
3.Area of rectangle
Please enter any of the above option: 2
Please enter base and height of triangle:
20
100
Area of triangle is: 1000.0