Assignment # 75 and Right Triangle
Code
/// Name: Tommy Oyuntseren
/// Period: 7
/// Program Name: RightTrig
/// File Name: RightTrig.java
/// Date: 1/26/2016
import java.util.Scanner;
public class RightTrig
{
public static void main(String [] args)
{
Scanner keyboard= new Scanner(System.in);
int s1, s2, s3;
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(s2 + " 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 2: ");
s3=keyboard.nextInt();
}
System.out.println("\nYour three sides are " + s1 +" "+ s2 +" "+ s3);
if ((s1*s1)+(s2*s2)==(s3*s3))
{
System.out.println("These sides DO make a right triange. Yippy-skippy!");
}
else
{
System.out.println("No! These sides do not make a right triangle.");
}
}
}
Picture of the output