|
- package tutorial;
-
- import java.util.Scanner;
-
- public class CalVolOfCylinder {
-
- public static void main (String [] args)
- {
- String strRadius , strLength;
- double radius , length, volume;
- Scanner input = new Scanner(System.in);
-
- System.out.print("Enter the radius: ");
- strRadius = input.nextLine();
-
- System.out.print("Enter the length: ");
- strLength = input.nextLine();
-
- radius = Double.parseDouble(strRadius);
- length = Double.parseDouble(strLength);
-
- volume = Math.pow(radius,2) * Math.PI * length;
- System.out.println("The volume of the cylinder with radius= " + radius + " and length= " + length + " is " + volume + ".");
-
- }
-
- }
|