Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In Java, I'm trying to write a program for the radius of the circle. I have the circle class mostly right. Just need help with
In Java, I'm trying to write a program for the radius of the circle. I have the circle class mostly right. Just need help with the main java class to run the following program.
Here's the code I've written so far:
radius of a circle. Your class will have the following internal field: . _radius-A float value that stores the radius of the circle It will also have the following public constant value declared and initialized properly. Make sure the value you declare is actually a constant and cannot be modified PI A float value initialized with the value 3.14159 Your class will have the following methods defined setRadius - Accepts a float for the radius fielod . getRadius - Returns the radius of the circle as a float. getDiameter - Returns the diameter of the circle as a float (radius 2) getArea - Returns the area of the circle (PI * radius radius) getCircumference - Returns the circumference of the circle (2 PI* radius) In addition, you will create a constructor that takes the radius (as a float) and stores the value in the_radius field. Your Circle class MUST have proper JavaDoc documentation for all public (external) methods, constructors and a summary of the class You will then write an application that prompts the user for the size of the circle and then output the radius, diameter, area and circumference of the specified circle. Your output should look like the following: Enter the radius of the circle: 12.2 Circle Properties Radius: Diameter: Area: Circumference: 76.7 12.2 24.4 467.6 Pay attention to the formatting of the output. For full credit, the output / formatting must be identical. Make sure that your sizes line up for easy reading. Decimals are expected to be output to one decimal place
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