continuous function and max/min values I would be happy if someone could give me a hand with this practice problem.

Given $f$ is continuous in the interval $[0, \infty)$, and $f(0) = \lim_{x\to\infty}f(x) = 0$, prove or disprove: $f$ attains a maximum and a minimum in the interval $[0, \infty)$.

Now, I approached this by creating a closed interval $[0,n]$, inside which $f$ is continuous. So by Weierstrass's second theorem I know that $f$ gets max/min values inside it. Now, if I'm given that the limit is zero when $x$ goes to $\infty$, I know that for any $\epsilon > 0$ , there exists $n>0$ such that, for any $x>n$, $|f(x)-0| < \epsilon \implies |f(x)| < \epsilon$.
I'm having trouble showing exactly how $f$ gets minimal or maximal values in the interval $[n, \infty)$. Also, I'm having trouble explaining how $f(0) = 0$ helps me define a minimal/maximal value when $x$ goes to $\infty$.
Thanks for any help.
 A: For a maximum: If $f(x)\le0$ for all $x$, there's nothing to show (the maximum value is $f(0)=0$). Otherwise, $f(c)=\alpha>0$ for some $c>0$. Choose $N>c$ so that $f(x)<\alpha/2$ for all $x\ge N$. This can be done since $\lim\limits_{x\rightarrow\infty} f(x)=0$. 
Now, $f$ attains a maximum value on $[0,N]$. Show that this in fact is the global maximum value of $f$ (note the maximum value on $[0,N]$ is at least $\alpha$). 
Argue in a similar manner to show $f$ attains a minimum value.
A: Hint: take a look at the functions $f_1(x) = \frac{1}{x+1}$ and $f_2(x) = -\frac{1}{x+1}$. Does $f_1$ reach it's minimum? How about $f_2$, does it achieve its maximum?
A: If $f(x)\le0$ for all $x\in[0,\infty)$, then the maximal value of $f$ is $0$, and it is attained in $x=0$.
If $f(x_0)>0$ for some $x_0\in[0,\infty)$, let $a=f(x_0)>0$ and $\varepsilon=\dfrac{a}{2}$. 
Since $f$ is continuous and $\lim_{x\to\infty}f(x)=0$, then there exists $N>0$ such that $|f(x)|<\varepsilon$, for all $x>N$.
The interval $[0,N]$ is compact, therefore $f$ attains a maximum value in these interval, said $M=f(x_m)$. Clearly we have that $M\ge a$ and then $M>\dfrac{a}{2} =\varepsilon> f(x)$, for all $x>N$. Hence $M$ is the maximum value of $f$ in $[0,\infty)$ attained at $x_m$.
The case of the minimal value is analogous.
Remark: We need to have the hypothesis $f(0)=\lim_{x\to\infty}f(x)$, otherwise we can take an increasing or decreasing monotone function which never attains the maximum or the minimum value, respectively.
