Implement a class Balloon that models a spherical balloon that is being filled with air. The constructor constructs an empty balloon, and other methods add air, and get the volume, surface area, and...


Java. Please use the template, thank you!


Implement a class Balloon that models a spherical balloon that is being filled with air. The constructor<br>constructs an empty balloon, and other methods add air, and get the volume, surface area, and radius.<br>Use this template: Balloon.java<br>Example:<br>Balloon balloon =<br>new Balloon();<br>balloon.getVolume (); // returns 0.0<br>balloon.getSurfaceArea (); // returns 0.0<br>balloon.getRadius () ; // returns 0.0<br>balloon.addAir(100);<br>balloon.getVolume () ; // returns 100.0<br>balloon.getSurfaceArea (); // returns 104.187942<br>balloon.getRadius (); // returns 2.879412<br>balloon.addAir(100);<br>balloon.getVolume (); // returns 200.0<br>balloon.getSurfaceArea (); // returns 165.388048<br>balloon.getRadius (); // returns 3.627832<br>

Extracted text: Implement a class Balloon that models a spherical balloon that is being filled with air. The constructor constructs an empty balloon, and other methods add air, and get the volume, surface area, and radius. Use this template: Balloon.java Example: Balloon balloon = new Balloon(); balloon.getVolume (); // returns 0.0 balloon.getSurfaceArea (); // returns 0.0 balloon.getRadius () ; // returns 0.0 balloon.addAir(100); balloon.getVolume () ; // returns 100.0 balloon.getSurfaceArea (); // returns 104.187942 balloon.getRadius (); // returns 2.879412 balloon.addAir(100); balloon.getVolume (); // returns 200.0 balloon.getSurfaceArea (); // returns 165.388048 balloon.getRadius (); // returns 3.627832
30 /**<br>* A class to represent an inflatable spherical balloon.<br>4<br>* /<br>6.<br>public class Balloon {<br>7<br>8.<br>// ADD YOUR INSTANCE VARIABLES EHRE<br>9.<br>100<br>11<br>12<br>130<br>/ **<br>* Constructs an unfilled balloon.<br>*/<br>public Balloon() {<br>// FILL IN<br>}<br>14<br>15<br>16<br>17<br>180<br>/**<br>19<br>* Inflates the balloon with a specified amount of air.<br>20<br>21<br>22<br>* @param amount the increase to the volume of the balloon (in cubic cm). Assume<br>* always >= 0.<br>23<br>240<br>25<br>26<br>*/<br>public void addAir(double amount) {<br>// FILL IN<br>}<br>27<br>28<br>290<br>/**<br>30<br>* Returns the volume of air currently inside the balloon.<br>31<br>32<br>33<br>340<br>@return the volume of air in the balloon (in cubic cm)<br>*<br>*/<br>public double getVolume () {<br>return -1.0; // FIX ME<br>35<br>36<br>37<br>38<br>390<br>40<br>/**<br>* Finds and returns the radius of the balloon.<br>41<br>* @return the radius of balloon (in centimeters)<br>42<br>43<br>440<br>45<br>46<br>47<br>48<br>490<br>*/<br>public double getRadius () {<br>return -1.0; // FIX ME<br>}<br>/**<br>* Finds and returns the surface area of the balloon.<br>50<br>51<br>52<br>53<br>540<br>* @return the surface area of balloon (in square centimeters)<br>* /<br>public double getSurfaceArea() {<br>return -1.0; // FIX ME<br>}<br>55<br>56<br>57 }<br>

Extracted text: 30 /** * A class to represent an inflatable spherical balloon. 4 * / 6. public class Balloon { 7 8. // ADD YOUR INSTANCE VARIABLES EHRE 9. 100 11 12 130 / ** * Constructs an unfilled balloon. */ public Balloon() { // FILL IN } 14 15 16 17 180 /** 19 * Inflates the balloon with a specified amount of air. 20 21 22 * @param amount the increase to the volume of the balloon (in cubic cm). Assume * always >= 0. 23 240 25 26 */ public void addAir(double amount) { // FILL IN } 27 28 290 /** 30 * Returns the volume of air currently inside the balloon. 31 32 33 340 @return the volume of air in the balloon (in cubic cm) * */ public double getVolume () { return -1.0; // FIX ME 35 36 37 38 390 40 /** * Finds and returns the radius of the balloon. 41 * @return the radius of balloon (in centimeters) 42 43 440 45 46 47 48 490 */ public double getRadius () { return -1.0; // FIX ME } /** * Finds and returns the surface area of the balloon. 50 51 52 53 540 * @return the surface area of balloon (in square centimeters) * / public double getSurfaceArea() { return -1.0; // FIX ME } 55 56 57 }
Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here