Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 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,2);
  12.       double radius_1 = radius + 0.5 ;
  13.       double volume_1 = (4.0/3) * Math.PI * Math.pow(radius_1,2);
  14.       double growth_1 = initial_volume - volume_1;
  15.       System.out.printf("Increase: %.0f", growth_1);
  16.       System.out.println(growth_1);
  17.       double radius_2 = radius_1 + 0.5 ;
  18.       double volume_2 = (4.0/3) * Math.PI * Math.pow(radius_2,2);
  19.       double growth_2 = volume_2 - volume_1;
  20.       System.out.printf("Increase: %.0f", growth_2);
  21.       System.out.println(growth_2);
  22.    }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement