Question
Create a class named Circle with:Data fields: Radius Default and custom constructors Methods Set radius Get radius Get circumference Get area Create three different instances
Create a class named Circle with:Data fields:
Radius
Default and custom constructors
Methods
Set radius
Get radius
Get circumference
Get area
Create three different instances of the circle with different values and store them in an ArrayList
I need to fix the program it said class, interface or enum expected in order to work. I don't know what to do to fix my code to work.
This is my program:
class Circle { private double radius; final private double PI = 22.0d/7.0d; public Circle() { } public Circle(double r) { radius = r; } public double getArea() { return PI*radius*radius; } public double perimeter() { return 2.0*PI*radius; } public double getRadius() { return radius; } public void setRadius(double radius) { this.radius = radius; } public double getPI() { return PI; } public String toString(){ return " Radius :"+radius+" , Area : "+getArea()+" "; } }
import java.util.ArrayList; import java.util.List;
public class CircleTest {
public static void main(String[] args) { List }
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