Assignment #75 and Right Triangle Checker
Code
/// Name: Graham Pollock
/// Period: 5
/// Program Name: RTChecker
/// File Name: RTChecker.java
/// Date Finished: 01/27/2016/
import java.util.Scanner;
public class RTChecker
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
int s1, s2, s3, left, right;
System.out.println("Enter three integers in ascending order:");
System.out.print("Side 1: ");
s1 = keyboard.nextInt();
System.out.print("Side 2: ");
s2 = keyboard.nextInt();
while (s2 < s1)
{
System.out.println( s2 + " is smaller than " + s1 + ". Try again.");
System.out.print("Side 2: ");
s2 = keyboard.nextInt();
}
System.out.print("Side 3: ");
s3 = keyboard.nextInt();
while (s3 < s2)
{
System.out.println( s3 + " is smaller than " + s2 + ". Try again.");
System.out.print("Side 3: ");
s3 = keyboard.nextInt();
}
System.out.println("Your three sides are " + s1 + " " + s2 + " " + s3);
left = (s1 * s1) + (s2 * s2);
right = (s3 * s3);
if (left == right)
{
System.out.println("Those sides do make a right triangle!");
}
else
{
System.out.println("Nope! those isdes don't make a right triangle!");
}
}
}
Picture of the output