Assignment 75
import java.util.Scanner;
public class RTC
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter three integers in ascending order.");
System.out.print("Side 1: ");
int side1 = keyboard.nextInt();
int side2, side3;
do
{
System.out.print("Side 2: ");
side2 = keyboard.nextInt();
if (side2 < side1)
{
System.out.println(side2+ " is less than " +side1+ ". Try again.");
}
} while (side2 < side1);
do
{
System.out.print("Side 3: ");
side3 = keyboard.nextInt();
if (side3 < side2)
{
System.out.println(side3+ " is less than " +side2+ ". Try again.");
}
} while (side3 < side2);
System.out.println("\nYour three sides are " +side1+ " " +side2+ " " +side3);
if (Math.pow(side1,2) + Math.pow(side2,2) == Math.pow(side3,2))
{
System.out.println("These three sides form a right triangle.");
}
else
{
System.out.println("These three sides do not form a right triangle.");
}
}
}