Assignment #75 Right Triangle Checker
Code
///Name: Ian Grant
///Period:5
///Project Name: Right Triangle Checker
///File Name:RghtTri.java
///12/08/15
import java.util.Scanner;
public class RghtTri
{
public static void main(String[] args)
{
int s1,s2,s3;
Scanner stuff= new Scanner(System.in);
System.out.println("Enter three integers: ");
System.out.print("Side 1: ");
s1=stuff.nextInt();
System.out.print("Side 2: ");
s2=stuff.nextInt();
while (s2< s1)
{
System.out.print(s2+" is smaller than "+s1+". Try again");
System.out.println("");
System.out.print("Side 2: ");
s2=stuff.nextInt();
}
System.out.print("Side 3: ");
s3=stuff.nextInt();
while (s3< s2)
{
System.out.print(s3+" is smaller than "+s2+". Try again");
System.out.println("");
System.out.print("Side 3: ");
s3=stuff.nextInt();
}
System.out.println("Your three sides are "+s1+" "+s2+" "+s3);
if (((s1*s1)+(s2*s2))==(s3*s3))
System.out.println("It is a right triangle");
else
System.out.println("No! These sides do not make a right triangle.");
}
}
Output