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

C++ PROGRAMMING: Exercise 1: Write the definition of a class, swimmingPool, to i

ID: 673111 • Letter: C

Question

C++ PROGRAMMING:

Exercise 1:

Write the definition of a class, swimmingPool, to implement the properties of a swimming pool.

Your class should have the instance variables to store (3 points)

- length (in feet)
- width (in feet)
- depth (in feet),
- rate (in gallons per minute) at which the water is filling the pool

The amount of gallons in one cubic feet is 7.48 gallons.

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 pool (5 points)

Explanation / Answer

#include <iostream>

using namespace std;

//Declaration of Class
class swimmingPool
{

//Declaration of instance variables of class to store length,breadth,height and rate respectively
double length;
double breadth;
double height;
double rate;

// Constructor to initialize instance varriables

public : swimmingPool(double x,double y, double z,double r)
{
    length=x;
    breadth=y;
    height=z;
    rate=r;
}

// Member functions to calculate amount of water needed to fill the empty tank.

// Logic is to calculate water needed first we need to calculate Volume of pool and then we need to calculate amount of water comes in that volume of pool.

// volume= length * breadth * height;

suppose volume= x cubic feet.

then if 1 cubic feet requires 7.48 gallons water then x cubic feet = x*7.48 gallons

double calculateAmount()
{
double VolumeOfPool= length*breadth* height;

double AmountofWater = VolumeOfPool*7.48;

return AmountofWater;
  
  
  
  
}};
int main()

{
    double l,b,h,r,result;
   cout << "Hello World" << endl;
      cout << "Length of pool" <<endl;
      cin>>l;
      cout << "Breadth of pool" <<endl;
      cin>>b;
      cout << "Height of pool" <<endl;
      cin>>h;
      cout <<"Rate at which water is filling the pool" <<endl;
      cin>>r;




swimmingPool pool(l,b,h,r);
result=pool.calculateAmount();
   cout<<"Amount of water needed to fill the tank is: "<<result<<" gallons";



   return 0;
}

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