/****************************************************************************** * This program checks a traingle to see if it is a right triangle. * * Copyright © 2020 Richard Lesh. All rights reserved. *****************************************************************************/ import org.pureprogrammer.Utils; public class PythagoreanTheorem { public static void main(String[] args) { final String HYPOTENUSE_STR = Utils.prompt("Hypotenuse: "); final String LEG1_STR = Utils.prompt("Leg #1: "); final String LEG2_STR = Utils.prompt("Leg #2: "); final double HYPOTENUSE = Utils.stodWithDefault(HYPOTENUSE_STR, 0.); final double LEG1 = Utils.stodWithDefault(LEG1_STR, 0.); final double LEG2 = Utils.stodWithDefault(LEG2_STR, 0.); final boolean IS_RIGHT_TRIANGLE = HYPOTENUSE * HYPOTENUSE == LEG1 * LEG1 + LEG2 * LEG2; System.out.println(Utils.join("", "Triangle is ", (IS_RIGHT_TRIANGLE ? "" : "NOT "), "a right triangle!")); } }