Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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_2

Step: 3

blur-text-image_3

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 Internals A Deep Dive Into How Distributed Data Systems Work

Authors: Alex Petrov

1st Edition

1492040347, 978-1492040347

More Books

Students also viewed these Databases questions

Question

Was there an effort to involve the appropriate people?

Answered: 1 week ago

Question

What is DDL?

Answered: 1 week ago