Assignemnt #75 and Right Triangle Checker
Code
///Name: Daniel Tiffany-Appleton
///Period: 7
///Program Name: Right Triangle Checker
///File Name: RightTriangleChecker
///Date Finished: 1/11/16
import java.util.Scanner;
public class RightTriangleChecker
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
System.out.println( "Enter three integers:" );
int sideOne = 1;
int sideTwo = 3;
int sideThree = 2;
System.out.print( "Side 1: " );
sideOne = keyboard.nextInt();
System.out.print( "Side 2: " );
sideTwo = keyboard.nextInt();
while( sideTwo < sideOne )
{
System.out.println( sideTwo + " is smaller than " + sideOne + ". Try again." );
System.out.print( "Side 2: " );
sideTwo = keyboard.nextInt();
}
System.out.print( "Side 3: " );
sideThree = keyboard.nextInt();
while( sideThree < sideTwo )
{
System.out.println( sideThree + " is smaller than " + sideTwo + ". Try again." );
System.out.print( "Side 3: " );
sideThree = keyboard.nextInt();
}
System.out.println( "Your three sides are " + sideOne + " " + sideTwo + " " + sideThree + "." );
int sides = (sideOne * sideOne) + (sideTwo * sideTwo);
int hypotenuse = (sideThree * sideThree);
if (hypotenuse == sides)
{
System.out.println( "These sides *do* make a right triangle. \"Yeah\". " );
}
else
{
System.out.println( "NO! These sides do not make a right triangle!" );
}
}
}
Picture of the output