Create a class named Circle with fields named radius, diameter, and area. Include a constructor that sets the radius to 1 and calculates the other two values. Also include methods named setRadius() and getRadius(). The setRadius() method not only sets the radius, but it also calculates the other two values. (The diameter of a circle is twice the radius, and the area of a circle is pi multiplied by the square of the radius. Use the Math class PI constant for this calculation.) Save the class as Circle.java.

Respuesta :

ijeggs

Answer:

The code for this class is shown in the explanation section

Explanation:

public class Circle {

   private double radius;

   private double diameter;

   private double area;

   public Circle(double radius, double diameter, double area) {

       this.radius = 1;

       this.diameter = diameter;

       this.area = area;

   }

   public void setRadius(double radius) {

       this.radius = radius;

       diameter = radius*2;

       area= Math.PI*(radius*radius);

   }

   public double getRadius() {

       return radius;

   }

}

RELAXING NOICE
Relax