daily pastebin goal
66%
SHARE
TWEET

Square

a guest Jan 20th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.lang.*;
  2. public class Square {
  3.  
  4.     private double side;
  5.  
  6.      Square(double side) {
  7.         this.side = side;
  8.     }
  9.  
  10.     Square(Circle c1) {
  11.         side = Math.sqrt(c1.getArea());
  12.     }
  13.  
  14.     public double getSide() {
  15.         return side;
  16.     }
  17.  
  18.     public double getArea() {
  19.         return side * side;
  20.     }
  21.  
  22.     public double getPerimeter() {
  23.         return side * 4;
  24.     }
  25.  
  26.     public Circle getInscribedCircle()
  27.     {
  28.         Circle c=new Circle(side/2);
  29.                 return c;
  30.     }
  31.     public Circle getCircumscribedCircle(){
  32.  
  33.         Circle c2 = new Circle(Math.sqrt(((side*side)+(side*side))/2));
  34.         return c2;
  35.     }
  36.     public static Circle[] getCircles(Square[] arr){
  37.         Circle[] arr2 = new Circle[arr.length];
  38.         for (int i=0;i<arr.length;i++)
  39.         {
  40.             arr2[i]= new Circle(arr[i]);
  41.         }
  42.         return arr2;
  43.     }
  44.  
  45. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top