I need help writing an equation that is taking the input from the user, three different sizes of paint containers in 4 different colors and converting it to the smallest unit, which would be pints. Then output the highest number of gallons sold.

for example:

input would be:

Red: 1 gallon, 2 quarts, and 1 pint

Green: 2 gallons, 1 quart, and 1 pint

Yellow: 1 gallon, 2 quart, and 0 pints

Blue: 0 gallons, 1 quart, and 1 pint

the total paint sold would need to output it as a sale to show that it was 5 gallons, 3 quarts, and 1 pint

basically the highest number of gallons with the highest remaining quarts and highest remaining pints

I have been trying for three days now to get this equation right and have to have it done by midnight.