Given:
A dairy needs 297 gallons of milk containing 6% butterfat.
To find the total gallons each of milk containing 8% butterfat and milk containing 2% butterfat must be used to obtain the desired 297 gallons:
Let x be the gallons of milk containing 8% butterfat.
So, 297-x be the gallons of milk containing 2% butterfat.
So that,

Since x=198,
297-x=297-198
That is, 99
Hence, 198 gallons of milk containing 8% butterfat and 99 gallons of milk containing 2% butterfat.