For some reason when I input 4 , 6 and 7, I get the wrong area. I don't know what I'm doing wrong, and it's driving me nuts. Any help would be appreciated.
import java.util.Scanner;
public class CaclulateAreaTriangle{
public static void main(String args[]){
Scanner scanner = new Scanner(System.in);
System.out.println("Enter the first side of the triangle:");
int a= scanner.nextInt();
System.out.println("Enter the second side:");
int b= scanner.nextInt();
System.out.println("Enter the third side:");
int c= scanner.nextInt();
if((a+b)>c && (a+c)>b && (b+c)>a)
{
int s=(a+b+c)/2;
double area=Math.sqrt(s*(s-a)*(s-b)*(s-c));
System.out.println("Area of Triangle is: " + area);
}
else
System.out.println("These Values Can Not Form a Triangle");
}
}