-
Notifications
You must be signed in to change notification settings - Fork 4
/
Area.java
42 lines (42 loc) · 1.16 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
import java.io.*;
import java.util.Scanner;
public class Area
{
float r,l,b,a,c,d,s;
double area1,area2,area3;
void area(float r)
{
area1=3.14*r*r;
System.out.println("Area of circle : "+area1);
}
void area(float l,float b)
{
area2=l*b;
System.out.println("Area of rectangle : "+area2);
}
void area(float a,float c,float d)
{
s=(a+c+d)/2;
area3=Math.sqrt(s*(s-a)*(s-d)*(s-c));
System.out.println("Area of triangle : "+area3);
}
public static void main(String args[])
{
float r,l,b,a,c,d;
Scanner in=new Scanner(System.in);
System.out.println("Enter the radius of circle");
r=in.nextFloat();
System.out.println("Enter the length of rectangle");
l=in.nextFloat();
System.out.println("Enter the breadth of rectangle");
b=in.nextFloat();
System.out.println("Enter the sides of the triangle");
a=in.nextFloat();
c=in.nextFloat();
d=in.nextFloat();
Area ob=new Area();
ob.area(r);
ob.area(l,b);
ob.area(a,c,d);
}
}