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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started