Question: Write a Circle class that has the following fields: Radius: a double PI: a final double initialized with the value 3.14159 The class

Write a Circle class that has the following fields: 

• Radius: a double
• PI: a final double initialized with the value 3.14159

The class should have the following methods: 

• Constructor. Accepts the radius of the circle as an argument.
• Constructor. A no-arg constructor that sets the radius field to 0.0.
• SetRadius. A mutator method for the radius field.
• GetRadius. An accessor method for the radius field.
• GetArea. Returns the area of the circle, which is calculated as Area = PI * radius * radius
• GetDiameter. Returns the diameter of the circle, which is Calculated as Diameter = radius * 2
• GetCircumference. Returns the circumference of the circle, which is calculated as Circumference = 2 * PI * radius

Write a program that demonstrates the Circle class by asking the user for the circle’s radius, creating a Circle object, and then reporting the circle’s area, diameter, and circumference. 

Step by Step Solution

3.48 Rating (158 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

public class Circle private double radius private final double PI 314159 public ... View full answer

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 Starting Out With Java From Control Structures Questions!