Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1.  
  2. /**
  3. * Write a description of class Sphere here.
  4. *
  5. * @author (your name)
  6. * @version (a version number or a date)
  7. */
  8. import java.util.Scanner;
  9. public class Sphere
  10. {
  11. public static void main(String [] args){
  12. //Initialize Variable
  13. double radius;
  14.  
  15. //Scanner Object
  16. Scanner keyboard = new Scanner(System.in);
  17.  
  18. //Heading
  19. System.out.println("Pedro's Sphere Surface Area And Volume Calculator");
  20. System.out.println(" =================================================");
  21.  
  22. //Ask user for radius
  23. System.out.print(" Enter the radius of the sphere: ");
  24. radius = keyboard.nextDouble();
  25.  
  26. //Display Volume
  27. System.out.print(" The volume of the sphere is: ");
  28. System.out.println(4.0/3 * Math.PI * Math.pow(radius, 3));
  29. //Spacer
  30. System.out.println("");
  31. //Display Surface Area
  32. System.out.print(" The surface area of the sphere is: ");
  33. System.out.println(4.0 * Math.PI * Math.pow(radius, 2));
  34.  
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement