Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.49 KB | None | 0 0
  1. package at.ac.fhstp.eidherr;
  2.  
  3. import java.util.Scanner;
  4. import java.lang.Math;
  5.  
  6. public class Bsp5 {
  7.  
  8.     public static void main(String[] args) {
  9.         Scanner input = new Scanner(System.in);
  10.         double a,b,c,a2,b2,c2;
  11.         System.out.println("Enter length of side a: ");
  12.         a=input.nextFloat();
  13.         System.out.println("Enter length of side b: ");
  14.         b=input.nextFloat();
  15.         System.out.println("Enter length of side c: ");
  16.         c=input.nextFloat();
  17. //      a=Math.sqrt(12.5);
  18. //      b=Math.sqrt(12.5);
  19. //      c=5;
  20.         a2=Math.pow(a, 2);
  21.         b2=Math.pow(b, 2);
  22.         c2=Math.pow(c, 2);
  23.         a2=roundDown(a2);
  24.         b2=roundDown(b2);
  25.         c2=roundDown(c2);
  26.        
  27.         if(c>=a+b || a>=b+c || b>=a+c) {
  28.             System.out.println("its not a triangle at all");
  29.             System.exit(0);
  30.         }
  31.         else if(a==b && a==c) {
  32.             System.out.println("its a same sided triangle");
  33.         }
  34.         else if(a2+b2==c2 && a==b) {
  35.             System.out.println("its a right angled same sided triangle");
  36.         }
  37.         else if(a==b & a!=c) {
  38.             System.out.println("its a same winged triangle");
  39.         }
  40.         else if((Math.pow(a, 2)+Math.pow(b, 2))==Math.pow(c, 2)) {
  41.             System.out.println("its a right angled triangle");
  42.         }
  43.         else {
  44.             System.out.println("its a regular triangle");
  45.         }
  46.        
  47.         int u = (int) (a+b+c), s=u/2;
  48.         double bigA = Math.sqrt((double)s*(s-a)*(s-b)*(s-c));
  49.        
  50.         System.out.printf("The circumverence of the triangle is %dcm, the surface area is %.2fcm² ", u, bigA);
  51.         input.close();
  52.     }
  53.    
  54.     public static double roundDown(double d) {
  55.         return ((long)(d* 1e12))/1e12;
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement