Create a class called Circle, which has (i) an attribute radius, (ii) a method that returns the current radius of a circle object, (iii) a method that allows the user to reset the radius of a circle, (iv) a method that calculates the area of the circle, and (v) a constructor that takes a number as parameter input and assign the number as the initial value of radius.

Respuesta :

Answer:

Explanation:

The following class is written in Java. I created the entire Circle class with each of the methods and constructor as requested. I also created a tester class to create a circle object and call some of the methods. The output can be seen in the attached picture below for the tester class.

class Circle {

   double radius;

   public Circle(double radius) {

       this.radius = radius;

   }

   public double getRadius() {

       return radius;

   }

   public void resetRadius() {

       radius = 0;

   }

   public double calculateArea() {

       double square = Math.pow((Math.PI * radius), 2);

       return square;

   }

}

Ver imagen sandlee09