|An object can float only if it is less dense than water. A floating object
displaces an amount of water equal
to its weight. We are given an object (that may or may not float) and a
container of water and we
want to calculate the water level that will result when we place the object
in the container. All weights are given in grams, all lengths are given in
centimeters, and a cubic centimeter of water weighs one gram.
The container is a tall rectangular box (with no top) with
horizontal dimensions wid x len. It is originally filled with water
to a height of waterHt. The object is a rectangular solid that is 1 x 1 x objHt.
The weight of the object is objWt. When placed in the water, the object
remains upright whether it floats or rests on the bottom.
Create a class Buoyancy that contains a method waterLevel that is given
wid, len, waterHt, objWt, and objHt and that returns the height of the water
after the object has been placed in the container.