Question: USING JAVA The surface area of a cylinder is written as: A = 2rh + 2r2 Write a program that prompts the user for a

USING JAVA

The surface area of a cylinder is written as:

A = 2rh + 2r2

Write a program that prompts the user for a radius and height of a cylinder and uses a method to calculate the surface area.

You will need:

A scanner object to read the radius and the height of the cylinder

Variables to store:

The radius (as a double)

The height (as a double)

(Optional: The area, which stores the returned area from the method. Again, keep in mind that you can use the method call directly in an output statement.)

A method that:

Accepts 2 parameters the radius and height

Calculates the area

Returns the area

Comments where necessary

Tip: Use the PI constant (from the Math Class) i.e. Math.PI - for .

A sample of the output is shown below:

Enter the cylinder's radius: 5.5 Enter the cylinder's height: 10 The surface area of a cylinder is: 535.6415474370597

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 Databases Questions!