Advertisement
rootUser

Online

May 28th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 2.30 KB | None | 0 0
  1. package online;
  2. import java.util.Scanner;
  3. public class Online
  4. {
  5.     public static void main(String[] args)
  6.     {
  7.         int m,n,o;
  8.         Scanner input = new Scanner (System.in);
  9.         m=input.nextInt();
  10.         n=input.nextInt();
  11.         o=input.nextInt();
  12.         Triangle ob=new Triangle();
  13.         ob.Area(1,1,1);
  14.     }
  15.    
  16. }
  17.  
  18. public class Triangle
  19. {
  20.     private int side1;
  21.     private int side2;
  22.     private int side3;
  23.    
  24.     public void SetSide(int a,int b,int c)
  25.     {
  26.         this.side1=a;
  27.         this.side2=b;
  28.         this.side3=c;
  29.     }
  30.     public boolean IsValid()
  31.     {
  32.         if(this.side1+this.side2>this.side3)
  33.         {
  34.             return true;
  35.         }
  36.         else
  37.         {
  38.             return false;
  39.         }
  40.     }
  41.     public int[] GetSide()
  42.     {
  43.         int[] b={this.side1,this.side2,this.side3};
  44.         return b;
  45.     }
  46.    
  47.     Triangle()
  48.     {
  49.         /*
  50.         this.side1=1;
  51.         this.side2=1;
  52.         this.side3=1;  
  53.         */
  54.     }
  55.     Triangle(int x,int y,int z)
  56.     {
  57.         this.side1=x;
  58.         this.side2=y;
  59.         this.side3=z;
  60.     }
  61.     public double Area(int a,int b)
  62.     {
  63.         return 0.5*a*b;
  64.     }
  65.     public double Area(int a,int b,int c)
  66.     {
  67.         float d=(a+b+c)/2;
  68.         float e=d*(d-a)*(d-b)*(d-c);
  69.         double f=Math.sqrt(e);
  70.         return f;
  71.     }
  72.    
  73.     public double Area(int a,int b,double c)
  74.     {
  75.         double f=Math.sin(c);
  76.         double d=0.5*a*b*f;
  77.         return d;
  78.     }
  79.    
  80.     public double Area(int x1,int y1,int x2,int y2,int x3,int y3)
  81.     {
  82.         double r1=x2-x1;
  83.         double k1=y2-y1;
  84.         double s1=Math.pow(r1,2);
  85.         double s2=Math.pow(k1,2);
  86.         double p=s1+s2;
  87.         double l1=Math.sqrt(p);
  88.        
  89.         double r2=x2-x3;
  90.         double k2=y2-y3;
  91.         double s3=Math.pow(r2,2);
  92.         double s4=Math.pow(k2,2);
  93.         double p1=s3+s4;
  94.         double l2=Math.sqrt(p1);
  95.        
  96.         double r3=x1-x3;
  97.         double k3=y1-y3;
  98.         double s5=Math.pow(r3,2);
  99.         double s6=Math.pow(k3,2);
  100.         double p2=s5+s6;
  101.         double l3=Math.sqrt(p2);
  102.        
  103.         double l=(l1+l2+l3)/2;
  104.        
  105.         double g=l*(l-l1)*(l-l2)*(l-l3);
  106.        
  107.         double k=Math.sqrt(g);
  108.        
  109.         return k;
  110.     }
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement