OneCompiler

AREA OF TRIANGLE

138

Write a program to define a method areaTriangle() that computes the area of a triangle using the heron's formula.

import java.util.;
public class areaTriangle
{
static void areaTriangle(double a , double b, double c)
{
double s = (a+b+c)/2;
double ar = Math.sqrt(s
(s-a)(s-b)(s-c));
System.out.println("THE AREA OF THE TRIANGLE IS : " + ar);
}
public static void main(String args[]) throws InstantiationException
{
Scanner sc = new Scanner(System.in);
System.out.println("PLEASE ENTER THREE SIDES OF THE TRIANGLE : " );
double s1 = sc.nextDouble();
double s2 = sc.nextDouble();
double s3 = sc.nextDouble();
areaTriangle(s1,s2,s3);
}
}

FOR CODE ,
CLICK : https://onecompiler.com/java/3xymue46n ( TO FIND OUTPUT )