Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Balloon
  4. {
  5. public static void main(String[] args)
  6. {
  7. Scanner in = new Scanner(System.in);
  8. System.out.print("Diameter: ");
  9. double diameter = in.nextDouble();
  10. double radius = diameter/2;
  11. double initial_volume = (4.0/3) * Math.PI * Math.pow(radius,3);
  12. double radius_1 = radius + 0.5 ;
  13. double volume_1 = (4.0/3) * Math.PI * Math.pow(radius_1,3);
  14. double growth_1 = volume_1 - initial_volume;
  15. System.out.printf("Increase: %.0f", growth_1);
  16. System.out.println();
  17. double radius_2 = radius_1 + 0.5 ;
  18. double volume_2 = (4.0/3) * Math.PI * Math.pow(radius_2,3);
  19. double growth_2 = volume_2 - volume_1;
  20. System.out.printf("Increase: %.0f", growth_2);
  21. System.out.println();
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement