Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write the definition of a class, swimmingPool, to implement the properties of a

ID: 3741341 • Letter: W

Question

Write the definition of a class, swimmingPool, to implement the properties of a swimming pool. Your class should have the instance variables to store the length (in feet), width (in feet), depth (in feet), the rate (in gallons per minute) at which the water is filling the pool, and the rate (in gallons per minute) at which the water is draining from the pool.

Add appropriate constructors to initialize the instance variables. Also add member functions, to do the following: Determine the amount of water needed to fill an empty or partially filled pool; the time needed to completely or partially fill the pool, or empty the pool; add water or drain for a specific amount of time. //user Input // Java

Explanation / Answer

public class SwimmingPool { private int length; private int width; private int depth; private double fillingRate; private double drainingRate; private double water; public SwimmingPool(int length, int width, int depth, double fillingRate, double drainingRate) { this.length = length; this.width = width; this.depth = depth; this.fillingRate = fillingRate; this.drainingRate = drainingRate; this.water = 0; } public void addWater(int time) { water += time*fillingRate; } public void drainWater(int time) { water -= time*drainingRate; if(water < 0) { water = 0; } } }