Assignment #75 and Right Triangle Checker
Code
/// Name: Ali Kurland
/// Period: 6
/// Program Name: Right Triangle Checker
/// File Name: RightTriangle.java
/// Date Finished: 10/20/2015
import java.util.Scanner;
public class RightTriangle
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int a, b, c;
System.out.println( "Enter three integers" );
System.out.print( "Side 1: " );
a = keyboard.nextInt();
System.out.print( "Side 2: " );
b = keyboard.nextInt();
while ( b < a )
{
System.out.println( b + " is smaller than " + a + ". Try again." );
System.out.print( "Side 2: " );
b = keyboard.nextInt();
}
System.out.print( "Side 3: " );
c = keyboard.nextInt();
while ( c < b )
{
System.out.println( c + " is smaller than " + b + ". Try again." );
System.out.print( "Side 3: " );
c = keyboard.nextInt();
}
System.out.println( "Your three sides are " + a + " " + b + " " + c );
if ( (a * a) + (b * b) == (c * c) )
System.out.println( "These sides *do* make a right triangle. Yay!" );
else
System.out.println( "NO! These sides do not make a right triangle!" );
}
}
Picture of the output