I am supposed to give an example of a sequence of Riemann integrable functions $f_{n}$ and $f$, all defined on $[0,1]$ such that $\lim f_{n}(x)=f(x)$ but $\lim \int_{0}^{1} f_{n} (x)dx\neq\int_{0}^{1}f(x)dx$.
What I can think of is $f_{n}(x)=\max\{n-n^2|x-\frac{1}{n}|,0\}$. The graphs actually converges to a "spike" but the integral for each $f_{n}$ is always $1$ and so I have $\lim \int_{0}^{1} f_{n} (x)dx\neq\int_{0}^{1}f(x)dx$.
However, I am not sure if $\lim f_{n}(x)=f(x)$ is true at all $x$ in $[0,1]$ for my example because the vertex $(\frac{1}{n},n)$ goes to infinity.
Your example, is correct: here's why.
It's better to write the above in a piecewise manner. Note that $f_n = n-n^2|x-\frac 1n|$ when $n > n^2|x-\frac 1n|$, or when $|x - \frac 1n| < \frac 1n$, or when $0 < x < \frac 2n$. Otherwise, it is $0$.
Clearly, the integral of each $f_n$ is $1$. But what is the limit function? That is, what is $\lim_{n\to \infty}f_n(x)$ for each $x$? Well, note that if $x=0$, then the limit is zero, since $f_n(0)=0$ for all $n$. If $x > 0$, then for some large enough $n$, $x > \frac 2n$, so $f_n(x) = 0$ beyond that point, and hence in the limit. Therefore, the limit function is $0$, and has integral zero, which means your example is correct.