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
An engineering firm just lost one of their larger customers. The firm president says that the solution to this problem is to fir
Shkiper50 [21]

Answer:

The engineers disagreed because their jobs were on the line

The ethical factors are:

The reason for the customer dumping the business is yet to be figured out

The need to keep cost to the lowest ebb in order to keep maintain profitability at the expense of employees' welfare

The are several ways of growing customer base which  are yet to be exploited.

Explanation:

The engineers disagree because there is no direct connection between the company's loss of the customer and their proposed layoff of the engineers,at least no one strong evidence has been given by the president.

The ethical factors inherent in this case are as follows:

The reason for the customer dumping the business is yet to be figure out

The need to keep cost to the lowest ebb in order to keep maintain profitability.

The are several ways of growing customer base which  are yet to be exploited.

There is  a need for a fact-finding exercise to establish the main motive behind losing such customer,without which the company can run into more troubles in future,otherwise the company would keep firing its good hands each time a customer dumps it.

Also,the president had resulted into such decision in order to maintain company's margins,where then lies ethics of welfare economics?Welfare economics is about looking beyond margins and looking at issues from a wider perspective of fulfilling the needs of employees in order for them to put in their best performance,at least by granting them job safety.

The company could have also grown business by investing in new technology that sets it apart from competitors instead of just jumping into the conclusions of sacking employees in a business where the company's strength lies in quality of engineers that it has.

7 0
3 years ago
What is Pressure measured from absolute zero pressure called?
7nadin3 [17]
Anything greater than total vacuum is technically a form of pressure
5 0
3 years ago
A vertical pole consisting of a circular tube of outer diameter 127 mm and inner diameter 115 mm is loaded by a linearly varying
Anna [14]

Maximum shear stress in the pole is 0.

<u>Explanation:</u>

Given-

Outer diameter = 127 mm

Outer radius,r_{2} = 127/2 = 63.5 mm

Inner diameter = 115 mm

Inner radius, r_{1} = 115/2 = 57.5 mm

Force, q = 0

Maximum shear stress, τmax = ?

 τmax  = \frac{4q}{3\pi } (\frac{r2^2 + r2r1 + r1^2}{r2^4 - r1^4} )

If force, q is 0 then τmax is also equal to 0.

Therefore, maximum shear stress in the pole is 0.

3 0
4 years ago
Why will screws never replace nails​
cupoosta [38]

Answer:

because people have different opinions on nails and screws

Explanation:

3 0
4 years ago
Gasoline has a comparatively high Btu per gallon rating of around
Shalnov [3]

Answer:

A

Explanation:

4 0
3 years ago
Other questions:
  • An old refrigerator consumes 247 W of power. Assuming that the refrigerator operates for 19 hours everyday, what is the annual o
    15·2 answers
  • A parison is extruded from a die with outside diameter = 11.5 mm and inside diameter = 7.5 mm. The observed die swell = 1.25. Th
    8·1 answer
  • Write a function called pyramid(height) that acceptsa parameter ""height"". It then prints a pyramid of that height
    10·1 answer
  • Drag each label to the correct location on the image.
    5·2 answers
  • 10. Identify one material we Mine and what we make with that material
    6·1 answer
  • Please help, Artificial Intelligence class test
    12·1 answer
  • Select the correct answer. The most frequent maintenance task for a car is: A. Oil changes B. Tire replacements C. Coolant chang
    10·2 answers
  • Determine the maximum height (in inches) that a lift pump can raise water (0.9971 g/ml) from a well at normal atmospheric pressu
    10·1 answer
  • A sprinter reaches his maximum speed in 2.5sec from rest with constant acceleration. He then maintains that speed and finishes t
    15·1 answer
  • Invent five new communication method wired or wireless you think would be practical
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!