Assignment #75
Code
/// Gian Adoremos
/// Period: 7
/// Program Name: SeventyFifth Program
/// File Name: RightTriangle.java
/// Date Finished: 1/14/2016
import java.util.Scanner;
public class RightTriangle
{
public static void main(String[] args)
{
int s1,s2,s3;
Scanner key= new Scanner(System.in);
System.out.println("three sides");
System.out.print("Side 1: ");
s1 = key.nextInt();
System.out.print("Side 2: ");
s2 = key.nextInt();
while (s2< s1)
{
System.out.print(s2+" is smaller than "+s1+". Try again");
System.out.println("");
System.out.print("Side 2: ");
s2 = key.nextInt();
}
System.out.print("Side 3: ");
s3 = key.nextInt();
while (s3< s2)
{
System.out.print(s3+" is smaller than "+s2+". Try again");
System.out.println("");
System.out.print("Side 3: ");
s3 = key.nextInt();
}
System.out.println("Your three sides are "+s1+" "+s2+" "+s3);
if (((s1*s1)+(s2*s2))==(s3*s3))
System.out.println("A right triangle, this is.");
else
System.out.println("A right triangle, this is not.");
}
}
Picture of the output