Solving Direct and Inverse Variation Problems