you are given the formula d=30-q. use it to find a formula for q using d.

This isn't physics. It is elementary algebra.

Add q - d to both sides of the equation