Answer to Question #300452 in Java | JSP | JSF for Stormcryp

Question #300452

(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

* TT

volume = area * length

Here is a sample run:


Enter the radius and length of a cylinder: 5.5 12 Enter

The area is 95.0331

The volume is 1140.4


1
Expert's answer
2022-02-20T17:13:27-0500
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.print("Enter the radius and length of a cylinder: ");
        double radius = in.nextDouble();
        double length = in.nextDouble();
        double area = radius * radius * Math.PI;
        double volume = area * length;
        System.out.println("The area is " + area);
        System.out.println("The volume is " + volume);
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS