There are 4 quarts in a gallon, so 4 quart cans would cost 4×5.99=$23.96, whereas a gallon can costs only $19.99. So it’s cheaper to buy a gallon can instead of 4 quart cans.
8 quarts=2 gallons, costing 2×19.99=$39.98 (2 gallon-cans),
2 quarts cost 2×5.99=$11.98.
Total cost of 10 quarts=39.98+11.98=$51.96.