Programming Assignment 4
DUE at the starting of the class on 10/01/2007 (Monday)
Do the following questions from the text book:

1) Exercise P4.10
Explain what each of the following two program segments computes:
int x = 2;
int y = x + x;

And
String s = “2”;
String t = s + s;

2) Exercise P4.16
What are the values of the following expressions? In each line assume that
double x = 2.5;
double y = -1.5;
int m = 18;
int n =4 ;
String s = “Hello” ;
String t = “World” ;

(a) x + n * y - (x + n) * y
(b) m / n + m % n
(c) 5 * x - n / 5
(d) Math.sqrt(Math.sqrt(n));
(e) (int) Math.round(x)
(f) (int) Math.round(x) + (int) Math.round(y)
(g) s + t;
(h) s + n;
(i) 1 - (1 - (1 - (1 - (1 - n))))
(j) s.substring(1,3)
(k) s.length() + t.length()



3) Exercise P4.10
Implement a class Balloon that models a spherical balloon that is being filled with air. The constructor constructs an empty balloon. 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 100 cm3 of air, tests the three accessor methods, adds another 100 cm3 of air and tests the accessor methods again.


Hand in to the instructor:
Hardcopy of the assignment, application and its output
Bring softcopy of java files, class files, HTML file in a folder (titled by your name).