Engine efficiency = power the engine outputs / power put into the engine. Power is just work over time, and time is 1s. So we have 4,000J/1s = 4000W out, and 12,000J/1s = 12,000W in.
This gives us 4000W/12,000W, which equals 0.333 or 33.3% (This number might seem low, but anything between 30-40% for a gas-powered engine is pretty good)
Carnot efficiency is the theoretical maximum efficiency of a heat engine. The equation you use to find it is:
max efficiency = 1 - (Tl/Th), where Tl is the temperature of the cold sink (air), and Th is the temperature of the hot sink (burning gasoline).
We get 1 - (304K/3000K) = 0.899 or 89.9%.
The theoretical maximum should always be higher than the actual amount. So to do a quick error check for problems like these, 89.9% should be > 33.3%. And they are, so things look good!