Let x = number of gallons used by the first car
Then, 45-x = number of gallons used by the other car
Then, 35x + 15(45-x) = 975
35x + 675 -15x = 975
20x = 300
x = 15 gal
The first car used 15 gal while the second car used 30 gal.