You can set this up in an algebraic expression which would be 3/12=4/x. The next step to this is cross multiplying which you would have to do 3(x), and 4(12). It should then look like 3x=48, then you would need to divide both sides by 3, when that is finished x should equal 16. The answer would be $16 for 4 gallons of milk.
I really hope that helped you!