-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharea.java
More file actions
22 lines (21 loc) · 829 Bytes
/
area.java
File metadata and controls
22 lines (21 loc) · 829 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import java.util.Scanner;
public class area {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
/*System.out.println("Enter the base of the triangle : ");
float base = reader.nextFloat();
System.out.println("Enter the height of the triangle : ");
float height = reader.nextFloat();
float area = (base * height) / 2F;
System.out.println("Area of the given Triangle is = " + area);*/
float a, b, c, s;
double area;
System.out.println("Enter Sides of the triangle :");
a = reader.nextFloat();
b = reader.nextFloat();
c = reader.nextFloat();
s = (a + b + c) / 2F;
area=Math.sqrt(s*(s-a)*(s-b)*(s-c));
System.out.println("Area of the given triangle is:"+area);
}
}