-
Notifications
You must be signed in to change notification settings - Fork 366
/
Copy pathExpression.java
44 lines (32 loc) · 964 Bytes
/
Expression.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
package expression;
import java.lang.*;
import java.util.*;
public class Expression
{
/* public static void main(String[] args)
{
float base,height,area;
System.out.println("Enter Base and Height");
Scanner sc=new Scanner(System.in);
base=sc.nextFloat();
height=sc.nextFloat();
area=base*height*0.5f;
//area=1f/2f*base*height;
//area=base*height/2;
System.out.println("Area of Triangle is "+area);
}
*/
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int a,b,c;
double s,area;
System.out.println("Enter 3 Sides of a Triangle");
a=sc.nextInt();
b=sc.nextInt();
c=sc.nextInt();
s=(a+b+c)/2f;
area=Math.sqrt(s*(s-a)*(s-b)*(s-c));
System.out.println("Area of Triangle is "+area);
}
}