[?] Calculate upper and lower sum (Riemann sum) for different functions?

Hi community!

I am a Mathematica beginner and want to solve the following problem. I am sure you can help me.

Task description:
There are given functions like
f(x)=cos(x^2),
g(x)=(x^2+1)^(1/2) and
h(x)=3^(2x+1) in an intervall of x ? [0,2]

I should calculate the upper sum
Riemann_uppersum.PNG

and lower sum.
Riemann_lowersum.PNG

And print the functions and segments afterwards.
I know how to solve this problem on paper, but i struggle with mathematica commands.

Thank you in advance and BR, Gabriel

n = 4;
xx = Table[2 (j - 1) / (n - 1), {j, 1, n}]
ff = Table[Cos[xx[[j]]^2], {j, 1, n}]
Sum[(xx[[j]] - xx[[j - 1]]) ff[[j]], {j, 2, n}]
Sum[(xx[[j]] - xx[[j - 1]]) ff[[j - 1]], {j, 2, n}]