Question: Rewrite the code in Circle.java and Main.java so that the Circle has a radius instance variable and 5 . 7 only needs to be used
Rewrite the code in Circle.java and Main.java so that the Circle has a radius instance variable and only needs to be used once in the entire program to set the value of the radius.
Delete the unnecessary local variables and parameters once the instance variable is set up
You may add a constructor to Circle.java or a setter method or both.
Add @Override before the toString method and make sure that the program still compiles.
class Main
public static void mainString args
Circle disk new Circle;
System.out.printlnThe
disk.toString has a circumference of
disk.getCircumference
and an area of disk.getArea;
import java.lang.Math;
class Circle
public double getCircumferencedouble radius
return MathPIradius;
public double getAreadouble radius
return Math.PIradiusradius;
public String toStringdouble radius
return "circle with radius radius;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
