Skip to content

Instantly share code, notes, and snippets.

@thmain
Created June 2, 2018 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thmain/342e3e3801e032b01fc02403262e7a89 to your computer and use it in GitHub Desktop.
Save thmain/342e3e3801e032b01fc02403262e7a89 to your computer and use it in GitHub Desktop.
public class AreaOfTriangle {
public static void area(double a, double b, double c){
//get the semi parameter
double s = (a + b + c)/2;
//find the area of triangle
double area = Math.sqrt(s*(s-a)*(s-b)*(s-c));
System.out.println("Area of triangle : " + area + " sq unit");
}
public static void main(String[] args) {
double a = 3.5;
double b = 4.5;
double c = 6.0;
area(a,b,c);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment