### Problem Statement

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.

### Definition

 Class: Buoyancy Method: waterLevel Parameters: double, double, double, double, double Returns: double Method signature: double waterLevel(double wid, double len, double waterHt, double objWt, double objHt) (be sure your method is public)

### Notes

-The returned value must be accurate to within a relative or absolute value of 1E-9

### Constraints

-wid and len will be between 1.2 and 10.0 inclusive.
-waterHt, objWt, and objHt will be between 0.1 and 500.0 inclusive.

### Examples

0)

 `2` `2` `100` `150` `80`
`Returns: 120.0`
 The object ends up on the bottom of the container, completely submerged. The final height of the water must be 120 since the total volume of the water and submerged object is 2*2*100 + 80 and that is equal to the new water level times the container's cross-section, 120*2*2.
1)

 `2` `2` `100` `150` `140`
`Returns: 133.33333333333334`
 This object also sinks, but does not get completely submerged. In the final situation, the total volume of the water and the part of the object that is submerged is 2*2*100 + 1*1*133.33 and that is equal to 2*2*133.3.
2)

 `2` `2` `100` `10` `160`
`Returns: 102.5`
 This object is very buoyant. It floats, with 10 units of its length submerged, displacing 10 grams of water. The total volume of the water and the submerged part of the object is then 2*2*100 + 10 and that is equal to 2*2*102.5.

#### Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=3932

#### Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=6550&pm=3932

dgoodman

#### Testers:

PabloGilberto , lbackstrom , vorthys

Geometry, Math