Heron's formula

Report a typo

Many years ago when Paul went to school, he did not like the Heron's formula to calculate the area of a triangle, because he considered it very complex. Once he decided to help all school students and write and distribute a program calculating the area of a triangle by its three sides.

However, there was a problem: as Paul did not like the formula, he did not memorize it. Help him finish this act of kindness and write the program calculating the area of a triangle with the known length of its sides, in accordance with Heron's formula:

S=p(pa)(pb)(pc)S=\sqrt{p(p-a)(p-b)(p-c)} where p=a+b+c2 p=\dfrac{a+b+c}2 is the half-perimeter of the triangle. In the input, the program has integers, and the output should be a real number corresponding to the area of the triangle.

Sample Input 1:

3
4
5

Sample Output 1:

6.0
Write a program in Java 17
class Main {
public static void main(String[] args) {
// put your code here
}
}
___

Create a free account to access the full topic