Just for Java Learning
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

27 行
757 B

  1. package tutorial;
  2. import java.util.Scanner;
  3. public class CalVolOfCylinder {
  4. public static void main (String [] args)
  5. {
  6. String strRadius , strLength;
  7. double radius , length, volume;
  8. Scanner input = new Scanner(System.in);
  9. System.out.print("Enter the radius: ");
  10. strRadius = input.nextLine();
  11. System.out.print("Enter the length: ");
  12. strLength = input.nextLine();
  13. radius = Double.parseDouble(strRadius);
  14. length = Double.parseDouble(strLength);
  15. volume = Math.pow(radius,2) * Math.PI * length;
  16. System.out.println("The volume of the cylinder with radius= " + radius + " and length= " + length + " is " + volume + ".");
  17. }
  18. }