Today We Will learn to find the area of a triangle using java
we know that area of triangle is half*base*height but here we will use the heron’s formula which will be like Area of triangle is equal to Square root of s(s – a)(s – b)(s – c) Where Is Semi Perimeter is s so now you getting how you can find semi perimeter in java it is very easy to find semi perimeter Firstly Find perimeter sum of all Side and semi perimeter is equal to half of perimeter
For Example
public class Main {
public static void main(String[] args) {
double side1=16.5,side2=14.6,side3=26;
double area,s=0;
//finding semi perimeter
s=(side1+side2+side3)/2;
area=Math.sqrt(s*(s-side1)*(s-side2)*(s-side3));
System.out.println("Area Of A triangle is "+area);
}
}
How To Find Square root in java Click Here
Today We Have Learned how you can find semi perimeter in java
how to find area of triangle in java
Making money as a coder in 2025 is not much of a big or tough…
Lloyds Technology Centre, A tech and data company located in Hyderabad, India. They are part of…
How to Increase Height at Any Age Rise Above: How to Increase Height at Any…
In the fast-paced digital world, we often forget the timeless beauty that nature offers. Today,…
Top 10 Deadliest Kicks in Martial Arts: Master the Art of Knockouts Martial arts is…
How to Optimize Battery Life of Your Smartphone: Tips and Tricks for Prolonging Battery Health…
View Comments
Good post. I learn something new and challenging on sites I stumbleupon every day. It will always be exciting to read through content from other writers and use a little something from other sites.