Step 1: Write the given function.
The function is
\[
f(x)=\cos x+\sin^2 x
\]
defined on the closed interval
\[
x\in[0,\pi]
\]
Since the interval is closed and continuous, the function must attain an absolute maximum and minimum.
Step 2: Differentiate the function.
Differentiate with respect to \(x\):
\[
f'(x)=-\sin x+2\sin x\cos x
\]
Factor out \(\sin x\):
\[
f'(x)=\sin x(2\cos x-1)
\]
Step 3: Find critical points.
Set
\[
f'(x)=0
\]
Thus
\[
\sin x(2\cos x-1)=0
\]
This gives
\[
\sin x=0
\]
or
\[
2\cos x-1=0
\]
First case:
\[
\sin x=0
\]
\[
x=0,\pi
\]
Second case:
\[
2\cos x-1=0
\]
\[
\cos x=\frac12
\]
\[
x=\frac{\pi}{3}
\]
Step 4: Evaluate the function at critical points and endpoints.
Compute \(f(x)\):
For \(x=0\):
\[
f(0)=\cos0+\sin^20
\]
\[
=1
\]
For \(x=\pi\):
\[
f(\pi)=\cos\pi+\sin^2\pi
\]
\[
=-1
\]
For \(x=\frac{\pi}{3}\):
\[
f\left(\frac{\pi}{3}\right)=\cos\frac{\pi}{3}+\sin^2\frac{\pi}{3}
\]
\[
=\frac12+\left(\frac{\sqrt3}{2}\right)^2
\]
\[
=\frac12+\frac34
\]
\[
=\frac54
\]
Step 5: Determine the absolute maximum.
The values obtained are
\[
1,\;-1,\;\frac54
\]
The largest value is
\[
\frac54
\]
Final Answer:
\[
\boxed{\frac54}
\]