-
1
- #1
Bellow is my code that calculate area of triangle where<br>a,b,c are sides of triangle and s is semiperimeter.program works fine,but I need main function call method Calcarea 3 times with different values for a,b and c.I'm very new in java.can't figure out how. Any help will be greatly appreciated.<br><br><br> public class Heron { <br><br> static int a=3,b=4,c=5,s=0,area=0;<br> <br><br> private static boolean IsValidTriangle(int a,int b,int c,int s) {<br> if (s>a && s>b && s>c)<br> return true;<br> else<br> return false; <br> } <br> private static int SemiPerimeter(int a, int b, int c) {<br> return s=(a+b+c)/2; <br> } <br><br> private static int CalcArea(int a, int b, int c,int s) {<br> <br> return area=(int)Math.sqrt(s*(s-a)*(s-b)*(s-c));<br> } <br><br> public static void main(String args[] ) {<br><br> <br> SemiPerimeter(a,b,c);<br> if (IsValidTriangle(a,b,c,s))<br>{<br> CalcArea(a,b,c,s);<br> System.out.println(