Heron's formula

Report a typo

A long time ago, in a galaxy far, far away, when Patricia went to school, she did not like to use the Heron's formula to calculate the area of a triangle, because it seemed too complicated to her. Once she decided to help all the school students. How? She must write and distribute the program, calculating the area of a triangle by its three sides!

However, there was a problem: since Patricia did not like the formula, she never memorized it. Help her finish this act of kindness and write the program, that calculates the area of a triangle using the 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 semi perimeter of a triangle. As the input, the program receives integers. The output is to be a real number, in our case, the area of the triangle.

Do not round the result.

Sample Input 1:

3
4
5

Sample Output 1:

6.0
Write a program in Kotlin
import kotlin.math.*

fun main() {
// put your code here
}
___

Create a free account to access the full topic