-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathareashapes.java
65 lines (51 loc) · 1.47 KB
/
areashapes.java
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
import java.util.Scanner;
class areas
{
void area(double ra)
{
double ar;
ar=3.14*ra*ra;
System.out.print("Area is: "+ar);
}
void area(int l,int b)
{
int ar;
ar=l*b;
System.out.print("Area is: "+ar);
}
void area(int b,float h)
{
double ar;
ar=0.5*b*h;
System.out.print("Area is: "+ar);
}
}
class areashapes
{
public static void main(String args[])
{
int ch;
Scanner s=new Scanner(System.in);
System.out.println("Do you want to find the area of:\n1.Circle\n2.Rectangle\n3.Triangle");
ch=s.nextInt();
areas obj=new areas();
switch(ch)
{
case 1: System.out.print("Enter the radius:");
double ra=s.nextInt();
obj.area(ra);
break;
case 2: System.out.print("Enter the length and breadth:");
int le=s.nextInt();
int br=s.nextInt();
obj.area(le,br);
break;
case 3: System.out.print("Enter the width and height:");
int wi=s.nextInt();
float hi=s.nextInt();
obj.area(wi,hi);
break;
default: System.out.print("Invalid choice!!");
}System.out.print("\n");
}
}