Assignemnt #75 Right Triangle
Code
/// Name: Caelan Dorstad
/// Period: 6
/// Program Name: RightTri
/// File Name: RightTri.java
/// Date Finished: 2/19/2016
import java.util.Scanner;
public class RightTri{
public static void main(String[] args){
Scanner keyboard = new Scanner(System.in);
int a,b,c;
System.out.print("1st side: ");
a = keyboard.nextInt();
System.out.println();
System.out.print("2nd side: ");
b = keyboard.nextInt();
System.out.println();
while ( b < a ) {
System.out.print(b+" is smaller than "+a+". Try again: ");
b = keyboard.nextInt();
System.out.println();
}
System.out.print("3rd side: ");
c = keyboard.nextInt();
System.out.println();
while (c < b){
System.out.print(c+" is smaller than "+b+". Try again: ");
c = keyboard.nextInt();
System.out.println();
}
int sum1 = (a^2 + b^2), sum2 = (c^2);
System.out.println("Your sides are "+a+" "+b+" "+c+".");
System.out.println();
if (sum1 == sum2){
System.out.println("Does form a right triangle!");
}
else
System.out.println("Doesn't form a right triangle!!!!!!!!!!!!");
}
}
Picture of the output