So you would set the triple integral up as you would for any other problem. This time though, you are simply dividing by volume. In 2D of course volume becomes area.
So if we were to calculate this for part 1 (a 2D figure. It is not actually a ball, rather a disk of radius a) we would need
For part 2 (a 3D figure we would need)
You can do this in spherical or in cylindrical co-ordinates.