COMS S1004

In-class Assignment #1

Assignment

In this assignment you will create a class called Balloon that models a (perfectly) spherical balloon that is being filled with air. The class should have an attribute called "volume" and also have the following methods:

  • getVolume: returns the volume of the balloon
  • addAir: takes a double as its argument and adds that much air to the balloon
  • getSurfaceArea: returns the surface area of the balloon
  • getRadius: returns the radius
Hint: take a look here in case you need help with the formulas.

Next, create a test class to show that your Balloon class works correctly. It should ask the user to input an amount of air to be added to the balloon, and then report its volume, surface area, and radius.

Solution is here: Balloon.java and BalloonTest.java. Check them after you're finished.