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
Aleksandr [31]
3 years ago
8

Implement a class Balloon that models a spherical balloon that is being filled with air. The constructor constructs an empty bal

loon. Supply these methods:
void addAir(double amount) adds the given amount of air.
double getVolume() gets the current volume.
double getSurfaceArea() gets the current surface area.
double getRadius() gets the current radius.

Supply a BalloonTester class that constructs a balloon, adds 100cm^3 of air, tests the three accessor methods, adds another 100cm3 of air, and tests the accessor methods again.

Computers and Technology
1 answer:
amm18123 years ago
6 0

Answer:

Here is the Balloon class:

public class Balloon {  //class name

private double volume;  //private member variable of type double of class Balloon to store the volume

 

public Balloon()  {  //constructor of Balloon

 volume = 0;  }  //constructs an empty balloon by setting value of volume to 0 initially

 

void addAir(double amount)  {  //method addAir that takes double type variable amount as parameter and adds given amount of air

 volume = volume + amount;  }  //adds amount to volume

 

double getVolume()  {  //accessor method to get volume

 return volume;  }  //returns the current volume

 

double getSurfaceArea()  {  //accessor method to get current surface area

 return volume * 3 / this.getRadius();  }  //computes and returns the surface area

 

double getRadius()  {  //accessor method to get the current radius

 return Math.pow(volume / ((4 * Math.PI) / 3), 1.0/3);   }  } //formula to compute the radius

Explanation:

Here is the BalloonTester class

public class BalloonTester {  //class name

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

      Balloon balloon = new Balloon();  //creates an object of Balloon class

      balloon.addAir(100);  //calls addAir method using object balloon and passes value of 100 to it

      System.out.println("Volume "+balloon.getVolume());  //displays the value of volume by getting value of volume by calling getVolume method using the balloon object

      System.out.println("Surface area "+balloon.getSurfaceArea());  //displays the surface area by calling getSurfaceArea method using the balloon object

             System.out.println("Radius "+balloon.getRadius());   //displays the value of radius by calling getRadius method using the balloon object

     balloon.addAir(100);  //adds another 100 cm3 of air using addAir method

       System.out.println("Volume "+balloon.getVolume());  //displays the value of volume by getting value of volume by calling getVolume method using the balloon object

      System.out.println("Surface area "+balloon.getSurfaceArea());  //displays the surface area by calling getSurfaceArea method using the balloon object

             System.out.println("Radius "+balloon.getRadius());    }  }  //displays the value of radius by calling getRadius method using the balloon object

//The screenshot of the output is attached.

You might be interested in
Joe is a florist and wants to increase his client base. How can he achieve this with the help of a computer?
madam [21]
A because sounds like the correct answer
8 0
3 years ago
Read 2 more answers
If someone could translate this that would be awesome. I understand why you wouldn’t, it’s very long but I can’t do it without m
Angelina_Jolie [31]

Answer:

01010000 01010010

01001111 01001101

01001111 01000011

01001111 01000100

01000101 00111010

00100000 01000111

01101100 01101001

0111

100 0110001

0110111 01100011

this is the best i could do

Explanation:

5 0
3 years ago
If A = 5 i + j abd B = 2k then A - B in equal to​
Leto [7]

the answer is A-B=5i+j-2k

8 0
3 years ago
As Kaydence reads a chapter in her anthropology text, she draws a network diagramming the relationships among the concepts descr
german

Answer:

visual encoding

Explanation:

According to my research on the three types of encoding methods, I can say that based on the information provided within the question Kaydence is best described as capitalizing on visual encoding. Which is the act of associating a certain something with a picture in order to store it into memory, as opposed of associating it with sound or words. In this situation Kaydence is associating it with a networking diagram she drew.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

5 0
3 years ago
Select the correct answer.
Korvikt [17]

Answer:

Wireless Internet Access

3 0
3 years ago
Read 2 more answers
Other questions:
  • Write a class that can make comparisons between the efficiency of the common methods from the List interface in the ArrayList an
    5·1 answer
  • One particularly effective form of providing feedback is for the receiver to ________. restate the message in his or her own wor
    14·1 answer
  • When you reach a YIELD sign, yield to cross traffic and ____ before you enter the intersection.
    14·2 answers
  • Which osi reference model layer includes all programs on a computer that interact with the network?
    13·1 answer
  • Briefly discuss constraints
    13·1 answer
  • Write a Python function called validateCreditCard that takes 8-digit credit card number as the input parameter (string value) an
    8·1 answer
  • Explain: The fetch part of fetch decode execute cycle
    6·1 answer
  • The Department of Homeland Security only deals with threats to national security and does not play a role in helping companies m
    13·1 answer
  • All conductors,buses,and connections should be considered
    13·1 answer
  • Write an algorithm for a program which inputs the lengths a, b and c of the three sides of a triangle. The program then determin
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!