A dairy needs 297 gallons of milk containing 6% butterfat. How many gallons each of milk containing 8% butterfat and milk containing 2% butterfat must be used to obtain the desired 297 gallons?

Let the number of gallon of 8% butterfat needed =M

Then, the number of gallons of 2% butterfat needed =297 - M

0.08M + 0.02 * [297 - M] =0.06 * 297, solve for M

M = 198 gallons of 8% butterfat will be needed

297 - 198 =99 gallons of 2% butterfat will be needed.