Assignment 75 and Right Tri
Code
///Matthew Hughs
///Period 5
///Rightri
///Rightri.java
///2/2/2016
import java.util.Scanner;
class Rightri
{
public static void main ( String [] args)
{
Scanner keyboard = new Scanner(System.in);
int one,two,three;
System.out.println("Enter the three sides of the triangle");
System.out.print("Side one : ");
one = keyboard.nextInt();
System.out.print("Side two : ");
two = keyboard.nextInt();
while ( two < one)
{
System.out.println("Sorry " + two + " is smaller than " + one + ", please try again");
two = keyboard.nextInt();
}
System.out.print("Side three : ");
three = keyboard.nextInt();
while ( three < two )
{
System.out.println("Sorry " + three + " is smaller than " + two + ", please try again");
three = keyboard.nextInt();
}
if ( (one * one) + (two * two) == ( three * three) )
{
System.out.println("These sides make a right triangle.");
}
else
System.out.println("These sides do not make a right triangle");
}
}
Picture of the output