Assignemnt #75 Right Triangle Checker
Code
///Name:Tyler Hart
///Period:5
///Project Name: Right Triangle Checker
///File Name:RightTriangle.java
///2/27/16
import java.util.Scanner;
public class RightTriangle
{
public static void main(String[] args)
{
int s1,s2,s3;
Scanner key= new Scanner(System.in);
System.out.println("three sides");
System.out.print("Side 1: ");
s1 = key.nextInt();
System.out.print("Side 2: ");
s2 = key.nextInt();
while (s2< s1)
{
System.out.print(s2+" is smaller than "+s1+". Try again");
System.out.println("");
System.out.print("Side 2: ");
s2 = key.nextInt();
}
System.out.print("Side 3: ");
s3 = key.nextInt();
while (s3< s2)
{
System.out.print(s3+" is smaller than "+s2+". Try again");
System.out.println("");
System.out.print("Side 3: ");
s3 = key.nextInt();
}
System.out.println("Your three sides are "+s1+" "+s2+" "+s3);
if (((s1*s1)+(s2*s2))==(s3*s3))
System.out.println("A right triangle, this is.");
else
System.out.println("A right triangle, this is not.");
}
}
Picture of the output