A spring is stretched 40mm by a force of 15w.what is the work done by the force

I assume you mean 15 Newtons not watts

F = k x
average force * distance = (15/2 ) Newtons * 0.040 meters = 0.30 Joules