You usually use the integral when you want to do a sum of infinitisemally (Blah, my spelling sucks.. :P) small parts of something... or a sum of infinitesmally small parts of something multiplied by something else...
For example... work..
W = Fs (Where s is the distance in the direction of the force... leaving out the vector dot product)
If you were to, instead of take s as a whole distance, break s up into differential elements of infinitesmally small value ds, the work done over this infinitesmally small distance would be:
dW = F ds
And that uses the concept of integrals in the sense that you want the TOTAL work done... i.e. the sum of all those differential elements:
W = dW1 + dW2 + dW3... + dWn
Where n is where the segments finally end at the final distance.
And since the integral is essentially an infinite amount of sums of small bits of... stuff... you can use its concept to find the total sum.
It's especially useful for the work done by a spring; since the force is non-constant overall, which would mean ks^2 wouldn't work as a formula...
So, you use the concept of the integral...
At anyone point, the difference in work from the point just before it would be:
dW = F ds
You know that the spring force is F = ks... so: (where k is a constant)
dW = ks ds (Where ds is an infinitesmally small difference in distance)
Since it would be long and boring to do this by hand, we use integration:
W = integral (ks)ds = 0.5*ks^2
And that's where that formula comes from...
I probably made a mistake somewhere in my vague, useless, inaccurate attempt at helping you out, so I don't mind if someone corrects me...
By the way, I think this should be in another forum. :P