I will guess that the "q2" in your question is "q squared"....
We commonly use the "^" symbol (shift-6) to denote exponentiation. So
"If f varies jointly as q^2 and h..."
Another tutor suggests using the given information to find the constant of variation to find an explicit formula. That is a perfectly good method; and if you are working many problems with the same quantities, it is probably the best way.
But for working a single problem, I prefer a different path to the answer.
The value of f for the given inputs is 24.
The value for q changes from 2 to 3; that is a factor of 3/2. Since the variation is with q^2, this change in q changes the value of f by a factor of 9/4.
The value of h changes from 2 to 5; a factor of 5/2. This changes the value of f by a factor of 5/2.