My solution keeps coming up as true and i cannot make it say false if it is not true. The question is to write a program that validates a triangle. Any two integers added together must be larger than the last number to be a triangle.
import java.util.Scanner; public class Triangle { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter three edges:"); int Sides = input.nextInt(); int C = Sides % 10; int RemainingNumber = Sides / 10; int B = RemainingNumber % 10; RemainingNumber = RemainingNumber / 10; int A = RemainingNumber % 10; if (A + B > C && A + B != C) System.out.println("Can edges" + A + "," + B + ", " + C + "form a triangle?" + "true"); else if (A + C > C && A + C != C) System.out.println("Can edges" + A + "," + B + ", " + C + "form a triangle?" + "true"); else if (B + C > C && B + C != C) System.out.println("Can edges" + A + "," + B + ", " + C + "form a triangle?" + "true"); else System.out.println("Can edges" + A + "," + B + ", " + C + "form a triangle?" + "false"); } }