Solution (source code)

= Solution

The probability density $|\psi_n(x)|^2$ is symmetric about $a/2$, while $x-a/2$ is antisymmetric. Therefore
$$
E_n^{(1)}=\int_0^a|\psi_n(x)|^2(x-a/2)\,dx=0.
$$
The use of a midpoint-zero electric potential matters: adding a constant potential would add the corresponding uniform energy shift.