Kamrul13981

3

Mar 1st, 2021
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.49 KB | None | 0 0
  1. package task3;
  2. class Triangle {
  3.     int x,y,z;
  4.     public double area(){
  5.         double s = (x+y+z)/2;
  6.         return Math.pow((s*(s-x)*(s-y)*(s-z)),.5);
  7.     }
  8.     public double perimeter(){
  9.         return (x+y+z)/2;
  10.     }
  11. }
  12.  
  13. public class Task3 {
  14.  
  15.    
  16.     public static void main(String[] args) {
  17.       Triangle t = new Triangle();
  18.         t.x= 3;
  19.         t.y = 4;
  20.         t.z = 5;
  21.         System.out.println(t.area());
  22.         System.out.println(t.perimeter());  
  23.     }
  24.    
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment