-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShapes.java
More file actions
67 lines (66 loc) · 1.3 KB
/
Shapes.java
File metadata and controls
67 lines (66 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import java.util.*;
public class Shapes
{
public float area(float radius)
{
return 3.14f * radius * radius;
}
public float area(float length,float breadth)
{
return length * breadth;
}
public int area(int side)
{
return side*side;
}
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
Shapes cal=new Shapes();
System.out.println("1.Circle");
System.out.println("2.Rectangle");
System.out.println("3.Square");
System.out.println("4.EXIT");
while(true)
{
System.out.println("Enter the choice:");
int choice=sc.nextInt();
switch(choice)
{
case 1:
{
System.out.println("------CIRCLE-------");
System.out.println("Enter the radius:");
float radius=sc.nextFloat();
System.out.println("Area:"+cal.area(radius));
break;
}
case 2:
{
System.out.println("------RECTANGLE-------");
System.out.println("Enter the Length of rectangle:");
float length=sc.nextFloat();
System.out.println("Enter the Breadth of rectangle:");
float breadth=sc.nextFloat();
System.out.println("Area:"+cal.area(length,breadth));
break;
}
case 3:
{
System.out.println("------SQUARE-------");
System.out.println("Enter the Size of square:");
int side=sc.nextInt();
System.out.println("Area:"+cal.area(side));
break;
}
case 4:
{
System.out.println("------Exit-------");
System.exit(0);
}
default:
System.out.println("Invalid choice");
}
}
}
}