Java Code Help pls these are the expected outputs Expected output Diameter: 10 I
ID: 3748724 • Letter: J
Question
Java Code Help pls
these are the expected outputs
Expected outputDiameter: 10 Increase: 173 Increase: 208After having done the hand calcuslation and pacudocods for a program that models inflating a spherical balloca, now implement the task in Java. Remember, first the balloon is inflated to have a certain diameter (which is provided as an input). Then you inflate the balloon so that the diameter grows by an inch, and display the amcunt the volume has grON. Repeat that step: grow the diameter by another inch and show the growth of the velume. Complete the following program Complete the following file Balloon.java 1 import Java.util.scanner 3 public class Balloon public static void nain(String[] args) Scanner in new 5canner(System.in). Systen.out.print("Dianeter:") double dianeter-in.nextDoubleO 1e 12 13 14 15 16 17 18 19 2e Systen.out.printf("Increase : Systen.out.println) %.ef", ..); · Systen.out.printf("Increase : Systen.out.println); %.ef. ,); , "
Explanation / Answer
BaloonVolInc.java
import java.util.Scanner;
public class BaloonVolInc {
public static void main(String[] args) {
// Declaring variables
double diameter, vol1, vol2, vol3, radius;
/*
* Creating an Scanner class object which is used to get the inputs
* entered by the user
*/
Scanner sc = new Scanner(System.in);
// Getting the input entered by the user
System.out.print("Enter the sphere diameter :");
diameter = sc.nextDouble();
System.out.println("Diameter :" + diameter);
radius = diameter / 2;
vol1 = (4 / 3.0) * Math.PI * radius * radius * radius;
diameter++;
radius = diameter / 2;
vol2 = (4 / 3.0) * Math.PI * radius * radius * radius;
System.out.printf("Increase:%.0f ", vol2 - vol1);
diameter++;
radius = diameter / 2;
vol3 = (4 / 3.0) * Math.PI * radius * radius * radius;
System.out.printf("Increase:%.0f", vol3 - vol2);
}
}
________________
Output#1:
Enter the sphere diameter :10
Diameter :10.0
Increase:173
Increase:208
_____________
Output#2:
Enter the sphere diameter :7.5
Diameter :7.5
Increase:101
Increase:127
__________Could you plz rate me well.Thank You
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.