-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquestion3.java
More file actions
27 lines (21 loc) · 800 Bytes
/
Copy pathquestion3.java
File metadata and controls
27 lines (21 loc) · 800 Bytes
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
import java.text.DecimalFormat;
import java.util.Scanner;
import static java.lang.Math.*;
public class question3
{
public static void main(String[] args)
{
Scanner input = new Scanner (System.in) ;
System.out.print("Side 1: ");
int a = input.nextInt() ;
System.out.print("Side 2: ");
int b = input.nextInt() ;
System.out.print("Side 3: ");
int c = input.nextInt() ;
float semiPerimeter = (float)a+b+c / 3 ;
float area = (float) sqrt ((semiPerimeter * (semiPerimeter-a) * (semiPerimeter-b) * (semiPerimeter-c) ));
DecimalFormat df = new DecimalFormat("#.##");
String areaRound = (df.format(area));
System.out.println("Area of the triangle: " + areaRound);
}
}