Shavit

Triangle

Oct 16th, 2013
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.80 KB | None | 0 0
  1. // Shavit Borisov
  2. // CW
  3.  
  4. import java.util.Scanner;
  5.  
  6. public class Triangle {
  7.  
  8.     public static void main(String[] args)
  9.    
  10.     {
  11.         Scanner in = new Scanner (System.in);
  12.        
  13.         int a, b, c;
  14.        
  15.         System.out.println("Enter the three sides of your triangle:");
  16.         a = Math.abs(in.nextInt());
  17.         b = Math.abs(in.nextInt());
  18.         c = Math.abs(in.nextInt());
  19.        
  20.         if ((a == b) || (b == c) || (a == c))
  21.             System.out.println("Isosceles triangle");
  22.         else if (Math.pow((double)a, 2) + Math.pow((double)b, 2) == Math.pow((double)c, 2) || Math.pow((double)c, 2) + Math.pow((double)b, 2) == Math.pow((double)a, 2) || Math.pow((double)a, 2) + Math.pow((double)c, 2) == Math.pow((double)b, 2))
  23.             System.out.println("Right triangle");
  24.         else
  25.             System.out.println("Just a regular triangle!");
  26.        
  27.         in.close();
  28.     }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment