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

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

ID: 3664016 • Letter: J

Question

Java

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.

Explanation / Answer

class SwimmingPool
{
   int length;
   int width;
   int depth;
   int rate_filling;
   int rate_draining;
   int water_available_total;
   int time_available_total;
   int water_available;
   int time_available;
   SwimmingPool(int l,int w,int d,int rf,int rd) //constructor to initialize the variables
   {
      length=l;
       width=w;
       depth=d;
       rate_filling=rf;
       rate_draining=rd;
   }
   void setAvailable(int water,int time) //method to set available water and time
   {
       water_available=water;
       time_available=time;
   }
   void setAvailable_Total(int water_total,int time_total) //method to set total water and time
   {
       water_available_total=water_total;
       time_available_total=time_total;
   }
   void getAvailable()       //method to display the available and required water and time
   {
      
       System.out.println("Total capacity of water :"+water_available_total);
       System.out.println(" Available amount of water :"+water_available);
       System.out.println(" Amount of water needed:"+(water_available_total-water_available));
       System.out.println("Total time required to fill :"+time_available_total);
       System.out.println(" Time used to fill :"+time_available);
       System.out.println(" Remaining time of needed:"+(time_available_total-time_available));

   }
   public static void main(String args[])
   {
       SwimmingPool sp=new SwimmingPool(25,15,40,88,44);
           sp.setAvailable_Total(3000,1000);
           sp.setAvailable(2000,500);  
           sp.getAvailable();
   }
}

  


  

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote