1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Bingel [31]
3 years ago
15

After having done the hand calculation and pseudocode for a program that models inflating a spherical balloon, 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 amount the volume has grown. Repeat that step: grow the diameter by another inch and show the growth of the volume.
Engineering
1 answer:
vampirchik [111]3 years ago
7 0

Answer:

Explanation:

CODE :

import java.util.Scanner; // required imports for the class

class Balloon { // class to run the code

public static void main(String[] args) { // driver method

Scanner in = new Scanner(System.in); // scanner class to get the data

System.out.print("Diameter: "); // message

double diameter = in.nextDouble(); // prompt

double growth = 1; // local variables

int c = 0;

while (c < 10) { // iterate over the loop

double radius = diameter / 2; // calculate the radius

double vol = ((double)4 / 3) * 3.14 * radius * radius * radius; // calculate the initial volume

diameter = growth + diameter; // update the diamter

System.out.printf("\nIncrease in the Diameter is : %.0f", growth); // message

System.out.println("\nNew Diameter is : " + diameter); // print the diameter

radius = diameter / 2; // calculate the new diameter

double growthvol = ((double)4 / 3) * 3.14 * radius * radius * radius; // calculate the new volume

System.out.printf("Increase in the Volume is : %.0f", growthvol - vol); // message

System.out.println("\nNew Volume is : " + growthvol); // message

c++; // increment the count

}

}

}

OUTPUT :

run 1 :

Diameter: 10

Increase in the Diameter is : 1

New Diameter is : 11.0

Increase in the Volume is : 173

New Volume is : 696.5566666666667

Increase in the Diameter is : 1

New Diameter is : 12.0

Increase in the Volume is : 208

New Volume is : 904.3199999999998

Increase in the Diameter is : 1

New Diameter is : 13.0

Increase in the Volume is : 245

New Volume is : 1149.7633333333333

Increase in the Diameter is : 1

New Diameter is : 14.0

Increase in the Volume is : 286

New Volume is : 1436.0266666666666

Increase in the Diameter is : 1

New Diameter is : 15.0

Increase in the Volume is : 330

New Volume is : 1766.25

Increase in the Diameter is : 1

New Diameter is : 16.0

Increase in the Volume is : 377

New Volume is : 2143.5733333333333

Increase in the Diameter is : 1

New Diameter is : 17.0

Increase in the Volume is : 428

New Volume is : 2571.1366666666668

Increase in the Diameter is : 1

New Diameter is : 18.0

Increase in the Volume is : 481

New Volume is : 3052.08

Increase in the Diameter is : 1

New Diameter is : 19.0

Increase in the Volume is : 537

New Volume is : 3589.5433333333335

Increase in the Diameter is : 1

New Diameter is : 20.0

Increase in the Volume is : 597

New Volume is : 4186.666666666667

run 2 :

Diameter: 7.5

Increase in the Diameter is : 1

New Diameter is : 8.5

Increase in the Volume is : 101

New Volume is : 321.39208333333335

Increase in the Diameter is : 1

New Diameter is : 9.5

Increase in the Volume is : 127

New Volume is : 448.6929166666667

Increase in the Diameter is : 1

New Diameter is : 10.5

Increase in the Volume is : 157

New Volume is : 605.82375

Increase in the Diameter is : 1

New Diameter is : 11.5

Increase in the Volume is : 190

New Volume is : 795.9245833333334

Increase in the Diameter is : 1

New Diameter is : 12.5

Increase in the Volume is : 226

New Volume is : 1022.1354166666666

Increase in the Diameter is : 1

New Diameter is : 13.5

Increase in the Volume is : 265

New Volume is : 1287.59625

Increase in the Diameter is : 1

New Diameter is : 14.5

Increase in the Volume is : 308

New Volume is : 1595.4470833333332

Increase in the Diameter is : 1

New Diameter is : 15.5

Increase in the Volume is : 353

New Volume is : 1948.8279166666664

Increase in the Diameter is : 1

New Diameter is : 16.5

Increase in the Volume is : 402

New Volume is : 2350.87875

Increase in the Diameter is : 1

New Diameter is : 17.5

Increase in the Volume is : 454

New Volume is : 2804.7395833333335

Description :

During the casting or the calculation of the volume and the radius the RHS needs to be casted for the numerator with the double datatype so as to clearly get the result. And that the formula is also been updated.

Hope this is helpful.

You might be interested in
What are the well-known effects of electricity​
Sever21 [200]

Answer:

Hence, the three effects of electric current are heating effect, magnetic effect and chemical effect.

3 0
3 years ago
Read 2 more answers
If an older multimeter is set to display its reading in megohms, what must you do to determine the correct value? Please help.
Gekata [30.6K]

Answer:

idk

Explanation:

8 0
3 years ago
The underground cafe has an operating cash flow of $187,000 and a cash flow to creditors of $71,400 for the past year. During th
Serggg [28]

Answer:

cash flow to stockholders = $39,700

Explanation:

Operating cash flow = $187,000

cash flow to creditors = $71,400

Net working capital = $28,000

Net capital spending =  $47,900

Cash flow to stockholders = ?

CFF = operating cash flow - net working capital - net capital spending

CFF = $187,000 - $28,000 - $47,900 = $111,100

CFF = cash flow to creditors + cash flow to stockholders

cash flow to stockholders = CFF - cash flow to creditors

cash flow to stockholders = $111,100 - $71,400 = $39,700

Hence $39,700 is the amount of the cash flow to stockholders for the last year.

3 0
3 years ago
Ben İngiliz oldum düzelte bilirmiyim
Lelu [443]

Answer:

What laguange is that?

Explanation:

7 0
3 years ago
In the last 5 meters of braking, you lose ___ of your speed.
expeople1 [14]

Answer:

answer is

a)

3/4

Explanation:

In the last 5 meters of braking, you lose 3/4 of your speed.

5 0
3 years ago
Other questions:
  • Name two types of Transformers.
    6·1 answer
  • Which solution causes cells to shrink
    13·1 answer
  • Explain how use of EGR is effective in reducing NOx emissions 4. In most locations throughout the U.S., the octane number of reg
    5·1 answer
  • A mass of 5 kg of saturated water vapor at 100 kPa is heated at constant pressure until the temperature reaches 200°C.
    6·1 answer
  • In a four-stroke engine, the piston rises in the cylinder, which triggers the _______ stroke.
    8·1 answer
  • Air pressure is higher above an airfoil.<br> true or false
    14·1 answer
  • In fully developed laminar flow in a circular pipe the velocity at R/2 (mid-way between the wall surface and the centerline) is
    10·2 answers
  • ⚠️Answer needed quick!!⚠️
    5·1 answer
  • Computer system analyst advantage​
    5·2 answers
  • A) If a given directional antenna can receive 15 times the power of an isotropic antenna, what is
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!