The lake where we vacation sometimes floods. As soon as the level reaches the
maximum level that
can be contained by the banks of the lake, the additional water covers a fixed
floodplain area, which enlarges the area of the lake. Below are views of the
lake from the side, with water indicated by X's.
| | | |
|___ ___| |XXXXXXXXXXXXXX|
| | |XXXXXX|
| | |XXXXXX|
|XXXXXX| |XXXXXX|
|XXXXXX| |XXXXXX|
(not flooded) (flooded)
The amount of evaporation depends on the surface area. When the lake is not
flooded, the evaporation is evapNormal units of water per day. When the lake is
flooded, the evaporation is evapFlood units per day. The lake never goes dry and never
extends beyond the floodplain.
Assume that the lake is initially full but not flooded. Create a class WaterLevel
that contains a method netAmt that is given evapNormal, evapFlood, and int[] rain,
the amounts of rain that fell on each day during our vacation. The method returns the net
increase (a positive value) or decrease (a negative value) in the units of water in the lake during
our vacation. The i-th element of rain tells how many units of water fell during the
entire i-th day. You should assume that it rains at a constant rate throughout the day.
|