Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program to calculate the volume and surface area of a cone. Allow the user to input the data initially, validate users input only

Write a program to calculate the volume and surface area of a cone. Allow the user to input the data initially, validate users input only when all input data are positive the program will calculate. If the data is not valid, all user to input again, maximum three times. Allow the user to change the radius and height of a cone. In the TestCone class, you need to create objects using different constructors at least once. for instance,

Cone cone1 = new Cone();

For each object, make sure the user can input the radius and height with valid values and display the final volume and surface area in GUI.

You need two constructors for the Cone class:

Cone() is a default constructor and

Cone(double r, double h) is a constructor that takes radius and height from user

You need to define following method in the Cone class:

//calculate the volume of a cylinder with radius of l, and height of h

public void findVolume(double l, double h)

// calculate the volume of a cylinder

public void findVolume()

// all accessor methods

public double getRadius()

public double getHeight()

// all mutator methods to change the radius and the height of the cone. The input data is from user.

public void setLength(double l)

public void setHeith(double h)

In the TestCone class:

Create two Cone objects using different constructor.

You need to display the volume of two Cone objects in GUI.

Knowledge Unit of Cone (Wiki)

A cone is a type of geometric shape. There are different kinds of cones. They all have a flat surface on one side that tapers to a point on the other side.

The surface area of a cone is the surface area of the outside of the cone plus the surface area of the circle at the end. There is a special formula used to figure this out.

Surface area = rs + r2

There is special formula for finding the volume of a cone. The volume is how much space takes up the inside of a cone. The answer to a volume question is always in cubic units.

Volume = 1/3r2h

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

Database Systems Design Implementation And Management

Authors: Peter Rob, Carlos Coronel

6th International Edition

061921323X, 978-0619213237

Students also viewed these Databases questions

Question

=+4 How did it affect HR?

Answered: 1 week ago