help with output and functions

Pages: 12
Fill Rate: 20 gal/min
Amount of water after adding water an additional 3 hours: 60 gallons

you are mixing hours and minutes, choose one and stick to it. remove any /60 that you have.
so get rid of the /60
im still getting zero for those three output
Time needed to drain the pool completely: 0hours
Amount of water left after draining half the pool: 0gallons

this is because you specified an empty pool
Amount of water in pool: 0 gallons


Time needed to fill the pool if it is half full: 0hours
this should be pool.timeToFillPool()/2.0
then what am i doing wrong then?
you still have /60 on time needed to fill pool, so you get 28.05 instead of 1683

0 is expected, 0 hours to drain an empty pool, 0 gallons left also.

I presume the remaining error is
Time needed to fill the pool if it is half full: 0hours
this should be pool.timeToFillPool()/2.0
no i still get 1683 when i take the /60 off
the zero are still there
and when i put the 2.0 it gives me 841.5 hours
cool.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
enter width
15
enter depth
10
enter the flow rate in
20
enter the flow rate out
19.5
enter the water in the pool (in gallons)
0
pool data
length: 30feet
width: 15 feet
depth: 10 feet
amount of water in pool : 0 gallons
fill rate : 20gal/hr
drain rate: 19.5gal/hr
water needed to fill the pool: 33660 gallons
time needed to fill the pool: 1683 hours
after filling pool to it capacity amount of water in pool: 33660
time needed to drain the pool completely:  0hours
amount of water left after draining half the pool: 0gallons
time need to fill the pool if it half full: 841.5 hours
amount of water after adding water for additional 3 hours 60gallons


you get the same as me now :)

the only thing wrong now (for both of us) is time need to fill the pool if it half full: 841.5 hours

this is because it presumes the pool is already 1/2 full. So you need another pool method

1
2
3
4
double timeToFillPoolFromEmpty()
{
   return poolTotalWaterCapacity() / waterFlowInRate;
}


now you can fix the broken stat with pool.timeToFillPoolFromEmpty()/2.0
instead of pool.timeToFillPool()/2.0

timeToFillPool() is based on water already in the pool. timeToFillPoolFromEmpty() isnt.
Last edited on
Topic archived. No new replies allowed.
Pages: 12