Prog75: Right Triangle Checker
///Name: Ilana Levy
///Period: 5
///Program Name: Right Triangle Checker
///File Name: rightTriangle.java
///Date Finished: 9/24/2015
import java.util.Scanner;
public class rightTriangle
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner( System.in );
int side1, side2, side3;
double right;
System.out.println("Enter three integers:" );
System.out.print( "Side 1: " );
side1 = keyboard.nextInt();
do
{
System.out.print( "Side 2: " );
side2 = keyboard.nextInt();
if ( side2 < side1 )
{
System.out.print( side2 + " is smaller than " + side1 + ". Try again." );
}
} while ( side2 < side1 );
do
{
System.out.print( "Side 3: " );
side3 = keyboard.nextInt();
if ( side3 < side2 )
System.out.print( side3 + " is smaller than " + side1 + ". Try again." );
} while ( side3 < side2 );
System.out.println( "Your three sides are " + side1 + " " + side2 + " " + side3 );
right = Math.sqrt( side1 * side1 + side2 * side2 );
if ( right == side3 )
System.out.println( "These sides *do* make a right triangle. Yippy- skippy!" );
else
System.out.println( "No! These sides do not make a right triangle!" );
}
}