Assignemnt #75 Right Triangle Checker
Code
/// Name: Jake Johnson
/// Period: 7
/// Program Name: RightTriangle
/// File Name: RightTriangle.java
/// Date Finished: 1/29/2016
import java.util.Scanner;
public class RightTriangle
{
public static void main (String[] args)
{
Scanner keyboard = new Scanner(System.in);
int side1, side2, side3;
System.out.println("Enter 3 integers:");
System.out.print("Side 1: ");
side1 = keyboard.nextInt();
System.out.print("Side 2: ");
side2 = keyboard.nextInt();
while (side1 > side2)
{
System.out.println(+ side2 + " is smaller than" + side1 + ". Try again.");
System.out.print("Side 2: ");
side2 = keyboard.nextInt();
}
System.out.print("Side 3: ");
side3 = keyboard.nextInt();
while (side2 > side3)
{
System.out.println(+ side3 + " is smaller than" + side2 + ". Try again.");
System.out.print("Side 3: ");
side3 = keyboard.nextInt();
}
System.out.println("\nYour three sides are " + side1 + " " + side2 + " " + side3);
if ((side1 * side1) + (side2 * side2) != (side3 * side3))
{
System.out.println("NO! These sides do not make a right triangle!");
}
else
{
System.out.println("These sides *do* make a right triangle. Yippy-skippy!");
}
}
}
Picture of the output