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

Write a program to calculate the cost and time it takes to fill a swimming pool.

ID: 3545652 • Letter: W

Question

Write a program to calculate the cost and time it takes to fill a swimming pool.


_ Inputs:

Length, Width, and Depth of the pool

Fill rate of the pool in Gallons per minute

_ Write a function to calculate the total cubic feet (Length x Width x Depth) and return the cubic feet.

*Inputs: Length, Width, and Depth  

*Output: Total cubic feet (cubic feet)

_ Write a function to calculate the number of gallons:

1 cubic foot = 7.48051948 US gallons (Create a constant to hold the conversion factor.)

*Output: Total gallons (gallons)

Example Prototype:

void PoolSize(float Length, float Width, float Depth, float &CubicFeet, float &Gallons);

_ Write a function to calculate the time to fill:

*Input to the function: Gallons

*Output: Hours and Minutes

Filltime= Gallons/Fillrate

Example Prototype:

void FillTime(float Gallons, float FillRate, ,float &Hours, float &Minutes);

Explanation / Answer

#include<iostream.h>


const float conv_fact=7.48051948;

void main()

{ void PoolSize(float length, float width, float depth, float *cubicfeet, float *gallons);

void FillTime(float Gallons, float FillRate,float *Hours, float *Minutes);


float length,width,depth,cubicfeet,gallons;

float FillRate,Hours,Minutes;

cout<<" Enter the pool dimensions(length,width,height)in inches: ";

cin>>length>>width>>depth;

PoolSize(length,width,depth,&cubicfeet,&gallons);

cout<<" Enter the Fillrate of the pool(Gallons per minutes): ";

cin>>FillRate;

FillTime(gallons,FillRate,&Hours,&Minutes);

cout<<" total size of pool in cubic feets is"<<cubicfeet<<" an in gallons is: "<<gallons<<" it will need "<<Hours<<" hours and "<<Minutes<<" minutes with the given fillrate";


}

void PoolSize(float length, float width, float depth, float *cubicfeet, float *gallons)

{ (*cubicfeet)=(length*width*depth)/12;

*gallons=(*cubicfeet)*conv_fact;


}

void FillTime(float gallons, float FillRate,int *Hours, int *Minutes)

{ float filltime=gallons*FillRate;

*Hours=int(filltime/60);

*Minutes=int(filltime)%60;

}

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