Just for Java Learning
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

27 rader
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. }