+ 1
How to calculate the area and the heights of the triangle in Java?
Input 3 numbers a, b, c Output area and heights
3 Respuestas
+ 4
Kind of an unclear question. What are the numbers a,b and c?
Are they the length of the sides?
If they are the length of the sides, then you can use the formula to get the area:
A=√(s(s-a)(s-b)(s-c))
where s=(a+b+c)/2
but there will be three heights for triangles which depends on the sides :
so you can get the heights :
h=A*2/(a or b or c)
Also show your attempt so that we can help you in your code.
+ 2
https://code.sololearn.com/co2J4Rj1u6M3/?ref=app
Thank you so much! This is my code.
+ 2
The only problem I can see in your code is, it takes input as int variable.So when the output is decimal it shows error.So just declare double of every variable so that it can take a decimal value:
https://code.sololearn.com/c51I7U8Z3JF/?ref=app