Your professor's comment is correct. Your calculation of the work done by the weight assumes a constant force, independent of compression x. However, the force law given (Hookes law) is variable and depends on the compression x. Because of the incorrect assumption, this led to you calculation of k being incorrect (too high) by a factor of two. After obtaining k, it is not clear that you performed the integral correctly in any case. You jumped from integral to answer. (Maybe your calculator allows this). Many problems require you to show all work and supply the missing step.