No sense in the expression $\hat{x}| 1\rangle=\sqrt{\frac{2}{a}}\int_{-\frac{a}{2}}^{\frac{a}{2}}x\cos\left(\frac{\pi}{a}x\right)dx=0$ I am considering a particle of mass m in a symmetric infinite square well of width a   in the fundamental state.
$$V(x)= \begin{cases} 0 & \mbox{$|x|<\frac{a}{2}$} \\ \infty  & \mbox{otherwise} \end{cases}$$

I want to know what values are obtained from the measurement of energy $E$, position $x$ and impulse $p$ and the corresponding probabilities.

So I did:
$$\psi_{n=1}(x)=\sqrt{\frac{2}{a}}\cos\left(\frac{\pi}{a}x\right)$$
$$E_{1}=\frac{\hbar^2\pi^2}{2ma^2} \,\,\,\,\,\,\,\,\,\,\ P(E_1)=100\%$$
I can not calculate the eigenvalues of the operator position that I imagine is a continuous set of values in the interval $\left[ -\frac{a}{2},\frac{a}{2} \right]$. 
Those that I have considered up until now are the eigenfunctions of the Hamiltonian and not of the position operator so I do not think it makes sense:
$$\hat{x}| 1\rangle=\sqrt{\frac{2}{a}}\int_{-\frac{a}{2}}^{\frac{a}{2}}x\cos\left(\frac{\pi}{a}x\right)dx=0$$
However I do not know how to do it or even for the momentum. 
I also have a suggestion that to calculate the probability of the momentum it is sufficient to calculate the wave function in the space of the impulses, but I honestly can not understand it
 A: @knzhou already indicated the perfect appositeness of your title.
You apply the definitions of your text, as the chthonian pundit suggests,
$$\hat{x}| 1\rangle= \hat{x}\int dx ~|x\rangle\langle x| 1\rangle= \sqrt{\frac{2}{a}}\int_{-\frac{a}{2}}^{\frac{a}{2}}dx~~\left( x\cos\left(\frac{\pi}{a}      x\right)\right )  ~~~|x\rangle  . $$
The position operator just multiplies the wavefunction by x for every position x, but, of course, the state $|1\rangle$ is an x -integral of eigenstates of this operator with x -dependent coefficients, the very heart of Dirac's Bra-Ket formalism. 
So, then,
$$\langle 1|\hat{x}| 1\rangle= \sqrt{\frac{2}{a}}\int_{-\frac{a}{2}}^{\frac{a}{2}}dx~~\left( x\cos\left(\frac{\pi}{a}      x\right)\right )  ~\langle 1|x\rangle   = \frac{2}{a} \int_{-\frac{a}{2}}^{\frac{a}{2}}dx~~\left( x\cos^2\left(\frac{\pi}{a}      x\right)\right )  =0  , $$
$\langle 1|\hat{x}^2| 1\rangle= a^2(1/12- 1/2\pi^2) $, etc.
You clearly naively calculated the eigenvalue of $\hat {p}^2$, since you have the eigenvalue of the energy; however, a subtlety  prevents $|1\rangle$ from being an eigenstate of of $\hat p$, as the symmetric wave packet $\langle p|1\rangle$ is not infinitely sharp. In any case, you may avoid all this; confirm directly that $\langle 1| \hat{p}|1\rangle =0$, which might not be surprising; and, of course, $\langle 1| \hat{p}^2|1\rangle =\hbar^2\pi^2/a^2$. This is just 10% off saturating the uncertainty principle bound!


*

*Small footnote to be avoided until the fourth reading. The moot self-adjointness of this $\hat p$ is fully discussed in here.

*
*

*Terms of use agreement, so in the smallest print possible, to only read with mental lawsuits in mind. In his book, Dirac defines $|x\rangle$ via the ''standard ket'' which, up to a normalization,  is but the translationally invariant momentum eigenstate $|\varpi\rangle=\lim_{p\to 0} |p\rangle$ in the momentum representation, i.e.,  $\hat{p}|\varpi\rangle=0$. Consequently, the corresponding wavefunction is a constant,  $\langle x|\varpi\rangle  \sqrt{2\pi \hbar}=1$. The definition is then $~~~|x\rangle= \delta(\hat{x}-x) |\varpi\rangle  \sqrt{2\pi \hbar}$.  


