Write a program that calculates the area and volume of a cylinder. Radius and height must be entered by the user. The area of a cylinder is 2 times base area added to the area of the side surface. The area of the side surface is multiplication of base circumference and height. The volume of a cylinder is base area multiplied by the height. You may assume PI is 3.14. Steps: Define two double variables radius and height and prompt the user to enter values for it. Define two double variables area and volume and calculate the values and store in these variables. Print the values of area and volume on the screen. Sample output: Enter radius and height of the cylinder: 2.5 3.5 Area: 94.2 Volume: 68.6875
Added by Jennifer Y.
Close
Step 1
First, we need to define the variables radius and height as doubles and prompt the user to enter values for them. We can use the Scanner class to get input from the user. ```java import java.util.Scanner; public class CylinderCalculator { public static void Show more…
Show all steps
Your feedback will help us improve your experience
Aman Gupta and 80 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
(Compute the volume of a cylinder) Write a program that reads in the radius and length of a cylinder and computes the area and volume using the following formulas: area = radius $\quad$ radius $* \pi$ volume $=$ area Here is a sample run:
"Write a program that gives the user the choice of computing of the following; the area of a circle, square, a rectangle, or a triangle: The program computes and refers to the following formulas: Choices: Area of circle = pi radius radius Area of square = side side Area of rectangle length width Area of triangle = %z base height (3) Area of Circle Area of Square Area of Rectangle Area of Triangle Let's assume these options: Your Choice: 4 1=> AREA OF CIRCLE 2=> AREA OF SQUARE 3-> AREA OF RECTANGLE 4=> AREA OF TRIANGLE Area of Triangle_ Enter base Enter height 6.0 5.0 Area is 15.00"
Florencia C.
(Compute the volume of a cylinder) Write a program that reads in the radius and length of a cylinder and computes the area and volume using the following formulas: area $=$ radius $*$ radius $^{*} \pi$ volume $=$ area ir length Here is a sample run: Enter the radius and length of a cylinder: 5.5,12 The area is 95.0331 The volume is 1140.4
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD