Question: Write in Java Write a Circle class that has the following fields: radius; a double the class should have the following methods: Circle (double r):
Write a Circle class that has the following fields: radius; a double the class should have the following methods: Circle (double r): the constructor for the Circle class. Get Radius: An method that returns the radius of a circle get Area: A method that returns the area of the circle, which is calculated as area: PI * radius * radius get Diameter: A method that returns the diameter of the circle, which is calculated as diameter: radius * 2 get Circumference: A method that returns the circumference of the circle, which is calculated as circumference = 2 * PI * radius Write a Test Circle class that will ask the user to enter a radius. the program will create a Circle object and will print the radius, diameter, area, and the circumference using the listed methods above. Use Decimal Format to format your output to have four decimal points after. Sample output: Please enter the radius of the circle This circle's radius is: 10.0000 This circle's diameter is: 20.0000 This circle's area is: 314.1593 This circle's circumference is: 62.8319
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
