Let x be the number of gallons you buy. Since each gallon cost $2.35 then the total cost of the gas would be:
[tex]2.35x[/tex]To this we have to add the car wash, then we have:
[tex]\text{2}.35x+6[/tex]Since we have $40 dollars we equate the expression above to this amount to find how many gallons we can buy:
[tex]2.35x+6=40[/tex]Solving for x we have:
[tex]\begin{gathered} \text{2}.35x+6=40 \\ 2.35x=40-6 \\ 2.35x=34 \\ x=\frac{34}{2.35} \\ x=14.47 \end{gathered}[/tex]Assuming we can only buy exact gallons you can buy 14 gallons.