The work done in the cannon has to be equal to the total energy of the cannonball when it leaves the barrel.
Work done:
[tex]W = \int\limits {\overrightarrow F \cdot} \, \overrightarrow {dx} = F \int\limits \, dx = Fx[/tex]
where F is the force on the cannonball and x is the length of the barrel.
The total energy of the cannonball:
[tex]E = \frac{1}{2} mv^2 + mgh[/tex]
where m is the mass of the ball, v is the velocity, g is the gravitational acceleration and h is the height above ground of the ball.
Combining both equations, where θ is the angle of the cannon:
[tex]Fx = \frac{1}{2} mv^2 + mgh = \frac{1}{2} mv^2 + mgxsin\theta \\ \\ m = \frac{Fx}{ \frac{1}{2} v^2 + gx sin\theta} = 12,29[/tex]