Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Balloon
- {
- public static void main(String[] args)
- {
- Scanner in = new Scanner(System.in);
- System.out.print("Diameter: ");
- double diameter = in.nextDouble();
- double radius = diameter/2;
- double initial_volume = (4.0/3) * Math.PI * Math.pow(radius,3);
- double radius_1 = radius + 0.5 ;
- double volume_1 = (4.0/3) * Math.PI * Math.pow(radius_1,3);
- double growth_1 = volume_1 - initial_volume;
- System.out.printf("Increase: %.0f", growth_1);
- System.out.println();
- double radius_2 = radius_1 + 0.5 ;
- double volume_2 = (4.0/3) * Math.PI * Math.pow(radius_2,3);
- double growth_2 = volume_2 - volume_1;
- System.out.printf("Increase: %.0f", growth_2);
- System.out.println();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement