Question: Java Help This is a review of inheritance Create a Sphere class that is derived from your Circle class. Add a method called volume (the
Java Help
This is a review of inheritance
Create a Sphere class that is derived from your Circle class. Add a method called volume (the volume of a sphere is 4/3 * pi*r*r*r) .
In your main method create two Spheres, print out their circumferences and volumes and then output the larger of the two (you must use compareTo).
double r1 = keyboard.nextDouble();
double r2= keyboard.nextDouble();
Sphere one=new Sphere( r1);
Sphere two = new Sphere(r2);
System.out.println(one.circumference());
System.out.println(one.volume());
//repeat for two
if(r1.compareTo(r2)>0).....you complete the rest
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
