If a tank is already 4/5, this means that it needs 1/5 more to be full. So, if 40 gallons of water is needed to fill the tank completely, this means that 1/5 of the tank is 40 gallons of water.
So to find the capacity of the tank, we just need to take 40 gallons times 5 which will give us 200 gallons.
Therefore, the capacity of the tank is 200 gallons.
Hope this helps!