Consider a one dimensional harmonic oscillator.
We have:
$$\hat{n} = \hat{a}^{\dagger} \hat{a} = \frac{m \omega}{2 \hbar} \hat{x}^2 + \frac{1}{2 \hbar m \omega} \hat{p}^2 - \frac{1}{2}$$
And:
$$\hat{H} = \hbar \omega (\hat{n} + \frac{1}{2})$$
Let's say we want to measure the total...