-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArea.java
57 lines (50 loc) · 1.19 KB
/
Area.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
import java.io.*;
import java.util.Scanner;
class Cal{
void Cal(int l,int b) {
int area= l*b;
System.out.println(area);
}
void Cal(double d) {
double area = 3.14*d*d;
System.out.println(area);
}
void Cal(double b,double h) {
double area= 0.5*b*h;
System.out.println(area);
}
}
public class Area{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
Cal ar=new Cal();
System.out.println("enter the shape to found the area");
System.out.println("if Area is circle- 1");
System.out.println("if Area is rect - 2");
System.out.println("if are is triangle -3");
System.out.println();
int c=sc.nextInt();
if(c==1)
{
System.out.println("enter the radius of cirle");
double rad=sc.nextDouble();
ar.Cal(rad);
}
else if(c==2) {
System.out.println("enter the lenght and breadth of rect");
int l=sc.nextInt();
int b=sc.nextInt();
ar.Cal(l,b);
}
else if(c==3)
{
System.out.println("enter the base and height of triangle");
double b=sc.nextDouble();
double h=sc.nextDouble();
ar.Cal(b,h);
}
else
System.out.println("invalid input");
}
}