First, you want to get the amount of square feet a quart of paint will cover. A gallon is four quarts. So you need to divide the square feet by four: 240/4=60 square feet covered by one quart of paint.
Next, you want to paint 300 square feet. If you divide the total square feet by the number covered by one quart, you will get the number of quarts. So: 300/60=5 quarts needed.
I didn't set up a formula for this. It really isn't necessary unless your assignment was specifically to set up a formula. ?