write this code to define the circle class and we will in 30 minutes to continue practice how to use the circle class and define more class
language java
class Circle{
double radius;
double area;
Circle(double r)
{
radius=r;
}
double getRadius(){ return radius; }
double computeArea()
{
return 3.14*radius*radius;
}
public String toString()
{
return "Radius : "+this.getRadius()+"\nArea
="+this.computeArea();
}
}
public class Main
{
public static void main(String[] args) {
Circle obj=new Circle(5.6);
System.out.println(obj);
}
}
Get Answers For Free
Most questions answered within 1 hours.