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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started