Question: PLEASE HELP (java) Modify the Circle class to include a member method named circumference. The circumference() method should return the circumference of the circle (2r).

PLEASE HELP (java)

Modify the Circle class to include a member method named circumference. The circumference() method should return the circumference of the circle (2r).

-----------------------------

Circle class that needs to be modified :

** * Circle class. */

public class Circle { private static double PI = 3.14; private double radius; /** * constructor * pre: none * post: A Circle object created. Radius initialized to 1. */ public Circle() { } /** * Changes the radius of the circle. * pre: none * post: Radius has been changed. */ public void setRadius(double newRadius) { } /** * Calcuates the area of the circle. * pre: none * post: The area of the circle has been returned. */ public double area() { } /** * Calcuates the circumference of the circle. * pre: none * post: The circumference of the circle has been returned. */ public double circumference() { } /** * Returns the radius of the circle. * pre: none * post: The radius of the circle has been returned. */ public double getRadius() {

}

}

-------------------------------

Test the class with the following client code:

public static void main(String[] args) { Circle spot = new Circle(); spot.setRadius(); System.out.println("Circle radius: " + spot.getRadius()); System.out.println("Circle circumference: " + spot.circumference()); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!