Write a Circle Classthat has the following fields: · Radius: adouble · PI: afina
ID: 3616397 • Letter: W
Question
Write a Circle Classthat has the following fields:
· Radius: adouble
· PI: afinal double initialized with the value 3.14159
The class should have the following methods:
· Constructor. Acceptsthe radius of the circle as an argument.
· 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 calculate as
area = PI * radius * radius
· getDiameter. Returnsthe diameter of the circle, which is calculated as
diameter = radius * 2
· getCircumference. Returnsthe circumference of the of the circle, which is calculated as
circumference = 2 * PI * radius
Write a program that demonstrates the Circle class by asking theuser for the circle’s radius, creating a Circle object,and then reporting the circle’s area, diameter, andcircumference.
Explanation / Answer
x.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.