Prompt for diameter and read user input = T x diameter x diameter x diameter / 6 volumel : diameter++ ebook-bjlo-1-ch02-sec4-rearrange-1 volume2 = T x diameter × diameter x diameter / 6 growth = volume2 - volumel Print growth diameter++ volume3 = Tx diameter x diameter x diameter /6 growth = volume3 - volume2 Print growth
After having done the hand calculation and pseudocode for a
Complete the following program.
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();
int volume1 = (pi*diameter*diameter*diameter/6);
System.out.printf("Increase: %.0f",diameter);
System.out.println();
int volume2 =(pi*diameter*diameter*diameter/6);
System.out.printf("Increase: %.0f",diameter);
System.out.println();
int growth = (volume2 - volume1);
int volume3 =(pi*diameter*diameter*diameter/6);
}
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 4 images