Answer
$$W = \frac{{245}}{6}{\text{in - lb}}$$
Work Step by Step
$$\eqalign{
& {\text{From the information we have:}} \cr
& F\left( x \right) = 5{\text{pounds}}{\text{ }}\left( {{\text{Variable force}}} \right) \cr
& x = 3{\text{inches}}{\text{ }}\left( {{\text{Variable distance}}} \right) \cr
& \cr
& {\text{Using Hooke's Law to find the spring constant }}k \cr
& F\left( x \right) = kx \cr
& 5 = k\left( 3 \right) \cr
& k = \frac{5}{3} \cr
& F\left( x \right) = kx \cr
& F\left( x \right) = \frac{5}{3}x \cr
& \cr
& {\text{The work required is }} \cr
& W = \int_a^b {F\left( x \right)} dx \cr
& {\text{Compressing the spring 7 inches, }}\underbrace {\left[ {0,7} \right]}_{\left[ {a,b} \right]} \cr
& W = \int_0^7 {\frac{5}{3}x} dx \cr
& {\text{Integrating}} \cr
& W = \frac{5}{3}\left[ {\frac{1}{2}{x^2}} \right]_0^7 \cr
& W = \frac{5}{3}\left[ {\frac{1}{2}{{\left( 7 \right)}^2} - \frac{1}{2}{{\left( 0 \right)}^2}} \right] \cr
& W = \frac{{245}}{6}{\text{in - lb}} \cr} $$