Assignemnt #76
Code
/// Name: Connor Siri
/// Period: 7
/// Program Name: Right
/// File Name: Right.java
/// Date Finished: 11/13/2015
import java.util.Random;
import java.util.Scanner;
public class Right
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
Random r = new Random();
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( a > b )
{
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 ( b > c )
{
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);
int w = ( a * a ) + ( b * b );
int z = ( c * c );
if ( w == z )
{
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