Integration question. The question is as follows

For any real number $x$, let $\lfloor{x}\rfloor$ denote the greatest integer less than or equal to $x$. Let $f$ be a real valued function defined on the interval $[-10,10]$ by
$f(x)=
\begin{cases}
x-\lfloor{x}\rfloor & \ \ \text{if} \ \lfloor{x}\rfloor \ \text{is odd} \\
1+\lfloor{x}\rfloor-x & \ \ \text{if} \ \lfloor{x}\rfloor \ \text{is even}
\end{cases}$
Then the value of $\dfrac{\pi^2}{10}\displaystyle\int_{-10}^{10} f(x) \ \cos{\pi x} \ dx$ is

My try--
$f(x)$ can be rewritten as 
$f(x)=
\begin{cases}
\{x\} & \ \ \text{if} \ \lfloor{x}\rfloor \ \text{is odd} \\
1-\{x\} & \ \ \text{if} \ \lfloor{x}\rfloor \ \text{is even}
\end{cases}$
Where $\{ \cdot\}$ denotes the fractional part function.
The graph of $f(x)$ will be somewhat like this, from $-10$ to $10$.

So, $\displaystyle\int_{-10}^{10} f(x) \ dx=10 \times \dfrac{1}{2} \times 2 \times 1=10.$
Then, using integration by parts, $$\displaystyle\int_{-10}^{10} \underbrace{f(x)}_{\text{2nd function}} \underbrace{\cos{\pi x}}_{\text{1st function}} \ dx=\left[\cos {\pi x} \cdot 10\right]_{-10}^{10}+\displaystyle\int_{-10}^{10}\pi\sin{\pi x} \cdot 10 \ dx \ \ \ \ \ \ \left(\text{because} \ \displaystyle\int_{-10}^{10} f(x) \ dx=10\right)$$
But my answer does not match that given in the book.

It is easier to note that the answer is (do you see why?)

$10*\displaystyle\int_{0}^{2} f(x)\cos(\pi x)dx=10*\displaystyle\int_{0}^{1} x\cos(\pi x)dx+10*\displaystyle\int_{1}^{2} (2-x)\cos(\pi x)dx$, and then use IBP (integration by parts) on that.


EDIT: Your mistake is actually something else in your IBP. Let the integral of $f(x)$ be denoted $F(x)$:

$\displaystyle\int_{-10}^{10} \underbrace{f(x)}_{\text{2nd function}} \underbrace{\cos{\pi x}}_{\text{1st function}} \ dx=\left[\cos {\pi x} \cdot F(x)\right]_{-10}^{10}+\displaystyle\int_{-10}^{10}\pi\sin{\pi x} \cdot F(x) \ dx $

When you integrate by parts, the function that isn't differentiated (that's integrated) isn't integrated definitely across the whole range but indefinitely inside the square brackets and the integral.
$\displaystyle\int_{0}^{1} u'vdx=\left[uv\right]_{0}^{1}-\displaystyle\int_{0}^{1}uv'dx$
Not $\displaystyle\int_{0}^{1} u'vdx=\left[v(\displaystyle\int_{0}^{1}udx)\right]_{0}^{1}-\displaystyle\int_{0}^{1}v'(\displaystyle\int_{0}^{1}udt)dx$
