Assignemnt #75 Right Triangle Checker
Code
///Name: Prooz Fereydouni
///Period: 7
///Project Name: Right Triangle Checker
///File Name: RTC.java
///Date: 1/26/2016
import java.util.Scanner;
public class RTC
{
public static void main(String [] args)
{
Scanner keyboard = new Scanner(System.in);
int s1, s2, s3;
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 (s1 > s2)
{
System.out.println("Second side is smaller. Try again.");
System.out.print("Side 2: ");
s2 = keyboard.nextInt();
}
System.out.print("Side 3: ");
s3 = keyboard.nextInt();
while (s2 > s3)
{
System.out.println("Third side is smaller. Try again.");
System.out.print("Side 3: ");
s3 = keyboard.nextInt();
}
System.out.println("Your three sides are: " + s1 + " " + s2 + " " + s3);
if (s1*s1 + s2*s2 == s3*s3)
System.out.println("The three sides would make a right triangle!");
else
System.out.println("The three sides would not make a right triangle");
}
}
Picture of the output