Question: I need help writing the program called CirclePrecomputedArea in java please! They all inherit each other and call to each other. i also included what

I need help writing the program called CirclePrecomputedArea in java please! They all inherit each other and call to each other. i also included what the output of running the superclass should look like! There are 4 different programs all together. There is CircleMain, CircleDynamicArea, Circle, and CirclePrecomputedArea.
Overall, you need to download and edit three files, namely:
Circle.java
CircleDynamicArea.java
CirclePrecomputedArea.java
You will need to write code in each of these files in order to make CircleMain.java compile and produce the correct output. As an example, under the command-line arguments 11.199.9 this should produce the
following output:
Initial dynamic area: 387.07563084879837
Initial precomputed area: 387.07563084879837
Reset dynamic area: 31353.126098752677
Reset precomputed area: 31353.126098752677
// TODO - write your code below this comment. // TODO - write your code below this comment.
// You need to do the following:
//
//1.) Define a class named CircleDynamicArea.
// This class inherits from Circle.
//
//2.) Define a constructor which takes a double
// to initialize the superclass with.
// You'll need to use super.
//
//3.) Define a getArea instance method, which
// returns the area of the circle calculated
// from the current radius of the circle.
// This can be determined from this expression:
//
// Math.PI *(getRadius()* getRadius())
//// TODO - write your code below this comment.
// You need to do the following:
//
//1.) Define a class named CirclePrecomputedArea.
// This class inherits from Circle.
//
//2.) Define an instance variable named area, which
// holds a double.
//
//3.) Define a constructor which takes a double
// to initialize the superclass with.
// You'll need to use super. Additionally,
// you'll need to set area to the area of this
// circle, using the same expression as you
// used in CircleDynamicArea
//
//4.) Define getArea to simply return the value
// in the area instance variable (just like
// a normal getter)
//
//5.) Override the setRadius method to recompute
// the value of the area, after setting the
// radius of the circle to the new value.
// You'll need to call the superclass' setRadius
// method with super.
//// DO NOT MODIFY ANYTHING IN THIS FILE!!
public class CircleMain {
public static void checkRadiusOk(double expectedRadius, Circle circle){
double haveRadius = circle.getRadius();
if (haveRadius != expectedRadius){
System.out.println("Radius mismatch! Expected: "+
expectedRadius +"...but we have: "+
haveRadius);
}
}
public static void main(String[] args){
double initialRadius = Double.parseDouble(args[0]);
double resetRadius = Double.parseDouble(args[1]);
Circle dyn = new CircleDynamicArea(initialRadius);
Circle pre = new CirclePrecomputedArea(initialRadius);
checkRadiusOk(initialRadius, dyn);
checkRadiusOk(initialRadius, pre);
double initialDynArea = dyn.getArea();
double initialPreArea = pre.getArea();
System.out.println("Initial dynamic area: "+ initialDynArea);
System.out.println("Initial precomputed area: "+ initialPreArea);
if (initialDynArea != initialPreArea){
System.out.println("Areas don't match initially");
} else {
dyn.setRadius(resetRadius);
pre.setRadius(resetRadius);
checkRadiusOk(resetRadius, dyn);
checkRadiusOk(resetRadius, pre);
double resetDynArea = dyn.getArea();
double resetPreArea = pre.getArea();
System.out.println("Reset dynamic area: "+ resetDynArea);
System.out.println("Reset precomputed area: "+ resetPreArea);
if (resetDynArea != resetPreArea){
System.out.println("Areas don't match after resetting the radius");
}
}
}
}
// You need to do the following:
//
//1.) Define an abstract class named Circle
//
//2.) Define an instance variable for Circle
// named radius. This variable holds a double.
//
//3.) Define a constructor which takes a
// double to initialize the radius instance
// variable with
//
//4.) Define a getter for radius
//
//5.) Define a setter for radius
//
//6.) Define an ABSTRACT method named getArea.
// Abstract methods are always instance methods.
//
I need help writing the program called

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Finance Questions!