+ 1

Triangle in java

Hello guys, I tried to solve this question Input the length of three sides of a triangle, calculate the area of the triangle, and output the results. It is suggested that if the three sides of triangle are a, b and c respectively, the formula for calculating the triangle area is as follows: S=(a+b+c)/2 Area = sqr s* (s-a)(s-b)(s-c) I wrote the code but im facing some problems with the BufferReader i dont know if i have to do a class and what to fill in the class, and IOExpetion facing the same issue, so please if you can help Iā€™ll appreciate This is the code https://code.sololearn.com/c6RWX5Aa8uD9/?ref=app

27th Apr 2021, 2:38 PM
HeeSo
HeeSo - avatar
6 Answers
+ 4
You line 34 has got a typo(formula mistake) replace it with - return(Math.sqrt(s*(s-a) * (s-b) * (s-c))); And the rest looks find. congrats.
27th Apr 2021, 5:19 PM
minirkk
minirkk - avatar
+ 2
Your BufferedReader is missing the letter 'd' (line 43) HeeSoKa Spelling wrong line 58 of "IOException" and add this- import java.io.IOException;
27th Apr 2021, 2:47 PM
minirkk
minirkk - avatar
+ 2
These are all needed to be imported. You don't need anything else. import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.IOException; There are lots of typo like IOException, BufferedReader, readLine().... *Typo formula of area. You wrote (c-a) where it should be (s-a).* Basically, your program has lots of incorrect spelling or typo. Not much of a problem.
27th Apr 2021, 2:57 PM
ä½ ēŸ„é“č¦å‰‡ļ¼Œęˆ‘也ę˜Æ
ä½ ēŸ„é“č¦å‰‡ļ¼Œęˆ‘也ę˜Æ - avatar
+ 1
thanks, so now the code is okay i dont have to change anything else right ?
27th Apr 2021, 4:29 PM
HeeSo
HeeSo - avatar
0
(S-k)
5th Jan 2022, 4:21 AM
Dominic Masse