Assignement: Right Triangle Checker
Code
/// Name: Sean Harrison
/// Period: 7
/// Program name: RightTriangleChecker
/// File Name: RightTriangle.java
/// Date Finished: 1/27/2016
import java.util.Scanner;
public class RightTriangle
{
public static void main( String [] args )
{
int sideA, sideB, sideC;
Scanner keyboard = new Scanner(System.in);
System.out.println ( " Right Triangle Checker " );
System.out.println ( " Side Hypotonuse: " );
sideA = keyboard.nextInt();
System.out.println ( " Side short leg: " );
sideB = keyboard.nextInt();
while ( sideA < sideB )
{
System.out.println( "Error " + sideB + " must be greater than " + sideA + " . ");
sideB = keyboard.nextInt();
}
System.out.println( "Side long leg: " );
sideC = keyboard.nextInt();
while ( sideC < sideB )
{
System.out.println( " Error " + sideB + " must be greater than " + sideC + " .");
sideC = keyboard.nextInt();
}
System.out.println( " Your three sides are " + sideA + " " + sideB + " " + sideC + " .");
if ( sideA * sideA == ( sideB * sideB) + ( sideC * sideC ) )
{
System.out.println( "These sides do indeed create a right triangle. " );
}
else
{
System.out.println( " These sides do not form a right triangle. " );
}
}
}
Picture of the output