Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

More Books

Students also viewed these Databases questions

Question

=+and non-compete agreements in three to five different countries.

Answered: 1 week ago