Let x be the number of buses, and y the number of cars.
[tex] \left \{ {{x+y=21} \atop {30x+4y=318}} \right. [/tex]
We can solve for y in the first equation to get:
[tex]y=21-x[/tex]
Now we can replace 21-x in our second equation, and solve for x:
[tex]30x+4(21-x)=318[/tex]
[tex]30x+84-4x=318[/tex]
[tex]26x=234[/tex]
[tex]x= \frac{234}{26} [/tex]
[tex]x=9[/tex]
We can conclude that 9 buses were needed for the trip.