Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help! I have most of the program put together, I'm just having trouble with the last class where I output the answers to the

Please help! I have most of the program put together, I'm just having trouble with the last class where I output the answers to the user. Any help will be greatly appreciated.

*all in the same java package*

Create an interface named Shape3D.java with the following code:

// An interface for three-dimensional shapes.

public interface Shape3D {

public double getVolume();

public double getSurfaceArea();

}

In the package create a class named Sphere.java, the class Sphere should implement the interface Shape3d. Define the class Sphere with following requirements:

// Represents a perfect sphere.

public class Sphere implements Shape3D {

//fill in instance fields required by a shape sphere

//Constructor

// Define a new method, return the radius

public double getRadius() {

// fill in corresponding statement to return the raduis

}

public double getSurfaceArea() {

. // Fill in statements return the surface area

}

public double getVolume() {

. //// Fill in statements return the volume

}

}

In the package create an abstract class named CircularShape.java which implements interface Shape3D. The abstract class CircularShape will work as a superclass.

// An abstract superclass for shapes with a circular cross-section.

public abstract class CircularShape implements Shape3D {

//fill in instance fields required

//Constructor

public double getDiameter() {

// fill in corresponding statement

}

public double getRadius() {

// fill in corresponding statement

}

public double getCrossSectionArea() {

// fill in statements to return the area of cross section

}

public double getCrossSectionPerimeter() {

// fill in statements to return the perimeter of cross section

}

}

In the package create an abstract class named CircularShapeWithHeight.java which extends CircularShape. The abstract class CircularShapeWithHeight will be defined with new field data and a new methods as following:

// An abstract superclass for shapes with a circular cross-section

// that extends over some height.

public abstract class CircularShapeWithHeight extends CircularShape {

// add new instance of height

// Constructor

..

public double getHeight() {

.// add statements return the height of the shape

}

}

In the package create a class named Cylinder.java which extends CircularShapeWithHeight. The class Cylinder will be defined as following:

// Represents a cylinder shape.

public class Cylinder extends CircularShapeWithHeight {

// instance fields

//Constructor

.

public double getSurfaceArea() {

...// Add statements here to return the surface of the cylinder

}

public double getVolume() {

..// add statements here to return the volume of the cylinder

}

}

In package you will create a class called testShapes.java. In the testShapes, created a static void main method where you will test the two different 3-dimensional shapes. You should use Scanner to let user input values from keyboard to define the shapes.

The output of running your testShape.java should be like following:

Please enter the radius for a sphere:

The radius you entered is 5.

The surface area of your sphere is 314.1592653589793 and its volumn is 523.5987755982989

Please enter the radius and height for a cylinder:

The radius is 5 and the height is 6.

The surface area of your Cylinder is 345.5751918948772 and its volume is 471.23889803846896

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Donald A. Carpenter Fred R. McFadden

1st Edition

8178088045, 978-8178088044

More Books

Students also viewed these Databases questions

Question

Discuss the key people management challenges that Dorian faced.

Answered: 1 week ago

Question

How fast should bidder managers move into the target?

Answered: 1 week ago