Assignment #75 and Right Triangle Checker
Code
/// Name: Lauren Baird
/// Period: 7
/// Program Name: Right Triangle Checker
/// File Name: RTC.java
/// Date Finished: 11/12/2015
import java.util.Scanner;
public class RTC
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int first, second, third;
System.out.println();
System.out.println( "Enter three intergers:" );
System.out.print( "Side 1: " );
first = keyboard.nextInt();
System.out.print( "Side 2: " );
second = keyboard.nextInt();
while ( second < first )
{
System.out.println( + second + " is smaller than " + first + ". Try again." );
System.out.print( "Side 2: " );
second = keyboard.nextInt();
}
System.out.print( "Side 3: " );
third = keyboard.nextInt();
while ( third < second )
{
System.out.println( + third + " is smaller than " + second + ". Try again." );
System.out.print( "Side 3: " );
third = keyboard.nextInt();
}
System.out.println();
System.out.println( "Your three sides are " + first + " " + second + " " + third + " " );
if ( first*first + second*second == third*third )
System.out.println( "These sides make a right triangle." );
else
System.out.println( "These sides don't make a right triangle." );
System.out.println();
}
}