title: java: using default constructors in calculations
body: <p>I have to write a program using constructors which calculates the area of a circle using 5 methods:</p>
  
  <p><strong>Circle</strong>: The constructor that creates a circle with radius = 1 </p>
  
  <p><strong>setRadius</strong>: takes an double argument and sets the radius to the argument </p>
  
  <p><strong>getRadius</strong>: returns an double argument with the value of the radius </p>
  
  <p><strong>computeDiameter</strong>: calculates the diameter and returns the value of the diameter </p>
  
  <p><strong>computeArea</strong>: calculates the area and returns the value of the area </p>
  
  <p>So far, I reached here..</p>
  
  <p>Main Class:</p>
  
  <pre><code>class MyClass{
  
  
          public static void main(String[] args) {
  
           MyClass1 circle= new MyClass1();
  
           System.out.println(circle.computeArea());          
  
          }
  
      }
  </code></pre>
  
  <p>This is the second class.. I haven't named it <em>Circle</em> though..</p>
  
  <pre><code>public class MyClass1 {
  
      private double radius;
      private double diameter;
      private double area;
  
      public MyClass1(){
  
          radius= 1.0;
      }
  
      public void setRadius(double radius){
  
          this.radius= radius;
      }
  
      public double getRadius(){
  
          return radius;
      }
  
      public double computeDiameter(){
  
          diameter= 2.0*radius;
          return diameter;
      }
  
      public double computeArea(){
  
          area= (Math.PI* Math.pow(diameter, 2))/4;
          return area;
      }
  </code></pre>
  
  <p>The problem is that the output for the area is giving me 0.0</p>