Assignment #75 and Right Triangle
Code
//Name: Mark Katz
///Period: 6
///Program Name: Right Triangles
///File Name: right.java
///Date Finished: 10/30/15
import java.util.Scanner;
public class right
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int s1, s2, s3;
double left, right;
System.out.println( "Enter three integers: ");
System.out.print( "Side 1: ");
s1 = keyboard.nextInt();
System.out.print( "Side 2: ");
s2 = keyboard.nextInt();
while ( s2 < s1 )
{
System.out.println( + s1 + " is smaller than " + s1 + ". Try again." );
System.out.print( "Side 2: ");
s2 = keyboard.nextInt();
}
System.out.print( "Side 3: ");
s3 = keyboard.nextInt();
while ( s3 < s2 )
{
System.out.println( + s3 +" is smaller than " + s2 + ". Try again." );
System.out.print( "Side 3: ");
s3 = keyboard.nextInt();
}
System.out.println( "Your three sides are " + s1 + " " + s2 + " " + s3 );
left = ( s1 * s1 ) + ( s2 * s2 );
right = ( s3 * s3);
if ( left == right )
{
System.out.println( "Those sides do make a right triangle." );
}
else
{
System.out.println( "Those sides don't make a right triangle." );
}
}
}
Picture of the output