Question

Write the definition of a class, Swimming Pool, to implement its properties and methods. Your class...

Write the definition of a class, Swimming Pool, to implement its properties and methods. Your class should have the instance variables to store: length (in meters), width (in meters), depth (in meters), rate (in liters per minute) at which the water is filling the pool, and rate (in liters per minute) at which the water is draining from the pool. This class’s functions are expected 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. Include also a Test class, to test the functionalities of the implemented classes.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please like! Thank you!

Program Plan: • Create the class swimming Pool. o Declare the instance variables. o Define the default constructor. o Define

Program: ******************* *This C++ program defines the class swimming Pool according* *to the question. * *** #include s

length = 0.0; width = 0.0; depth = 0.0; rate_fill = 0.0; rate_drain = 0.0; //Parameterized constructor. swimming Pool(double

void water_needed_to_fill(double time) double amount; //Calculate the capacity of pool double capacity = length*width*depth*7

cout << \nAmount of water needed to

<< fill the remaining pool: ; cout << capacity - amount << gallons ; // Define the function time_to_fill that //determine

double remain = capacity - amount; cout <<Time required to fill the pool is: ; cout << remain / rate_fill << minutes; //D

l/that drains the water for specific time. double drain_for_specific_time() double time; cout << Enter the time for which is

cout << Enter the length of the pool (in feet): ; cin >> length; cout<<Enter the width of the pool (in feet): ; cin >> wi

cin >> time_fill;

//Create the object of class swimming Pool swimming Pool sp(length, width, depth, rate_fill, rate_drain); //Call the function

Sample Output: Enter the length of the pool (in feet): 10 Enter the width of the pool (in feet): 20 Enter the depth of the po

Add a comment
Know the answer?
Add Answer to:
Write the definition of a class, Swimming Pool, to implement its properties and methods. Your class...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write the definition of a class, swimmingPool, to implement the properties of a swimming pool. Your...

    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. 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; the time needed to completely...

  • A swimming pool is 50 m long and 20 m wide. Its depth decreases linearly along...

    A swimming pool is 50 m long and 20 m wide. Its depth decreases linearly along the length from 9 m to 1 m. It is initially empty and is tilled at a rate of 1 m^3/min. How fast is the water level rising 810 min after the filling begins? How long will it take to fill the pool? The water is rising at a rate of m/min 810 min after the filling begins. (Simplify your answer.)

  • There is water being taken/pumped out of a swimming pool that it round. The pool has...

    There is water being taken/pumped out of a swimming pool that it round. The pool has a radius of R= 2.52m and it currently filled to a depth of ha=3.52m. The drain hose has a radius of rc=0.0316m. The height of the water at point A is slowly decreasing at a rate of 6.18cm/per minute. What us the velocity of the water through the drainpipe Vc=? What is the height hd of the water in the vertical tube, while the...

  • Bucket Management – In this programming exercise you will create a simple bucket management program according...

    Bucket Management – In this programming exercise you will create a simple bucket management program according to the following customer specifications: Write the definition of a class Bucket, to implement the properties and functions of a bucket. The bucket must be Cylinder shaped of any dimension. (20%) The class should have the instant variables to store the height (in feet), radius (in feet), amount (in cubic feet) of water in the bucket, the rate (in gallons / minute), at which...

  • For this computer assignment, you are to write a C++ program to implement a class for...

    For this computer assignment, you are to write a C++ program to implement a class for binary trees. To deal with variety of data types, implement this class as a template. The definition of the class for a binary tree (as a template) is given as follows: template < class T > class binTree { public: binTree ( ); // default constructor unsigned height ( ) const; // returns height of tree virtual void insert ( const T& ); //...

  • Java Project For this assignment, you will write a simulation program to determine the average waiting...

    Java Project For this assignment, you will write a simulation program to determine the average waiting time at a grocery store checkout while varying the number of customers and the number of checkout lanes. Classes needed: SortedLinked List: Implement a generic sorted singly-linked list which contains all of the elements included in the unsorted linked list developed in class, but modifies it in the following way: delete the addfirst, addlast, and add(index) methods and instead include a single add method...

  • Needs Help with Java programming language For this assignment, you need to write a simulation program...

    Needs Help with Java programming language For this assignment, you need to write a simulation program to determine the average waiting time at a grocery store checkout while varying the number of customers and the number of checkout lanes. Classes needed: SortedLinked List: Implement a generic sorted singly-linked list which contains all of the elements included in the unsorted linked list developed in class, but modifies it in the following way: • delete the addfirst, addlast, and add(index) methods and...

  • Objectives You will implement and test a class called MyString. Each MyString object keeps track ...

    Objectives You will implement and test a class called MyString. Each MyString object keeps track of a sequence of characters, similar to the standard C++ string class but with fewer operations. The objectives of this programming assignment are as follows. Ensure that you can write a class that uses dynamic memory to store a sequence whose length is unspecified. (Keep in mind that if you were actually writing a program that needs a string, you would use the C++ standard...

  • In Problem Set 7 you designed and implemented a Message class. This time, let's design and...

    In Problem Set 7 you designed and implemented a Message class. This time, let's design and implement a Mailbox class in a file named Mailbox java. Do the following with this class • You may use the Message class from PS 7. You will have to add new features to the Message class from PS 7 as you work through this problem. You are welcome to start with my sample solution if you wish • Suppose there are multiple mail...

  • Exercise 2 Separation of a Mixture Based on Acid-Base Properties One purpose of this exercise is...

    Exercise 2 Separation of a Mixture Based on Acid-Base Properties One purpose of this exercise is to learn how to use a separatory funnel to extract a single component away from other compounds in solution. To do so, we will apply the principles of solubility and acid-base behavior you’re seeing in class. One of the compounds is neutral in the acid-base sense. It has no ability to either donate or accept a proton from an aqueous solution, and will remain...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT