Graph of $y = a \sin \dfrac{\pi x}{L}$

Differential area

$dA = y \, dx$

$dA = a \sin \dfrac{\pi x}{L} \, dx$

Area by integration

$\displaystyle A = a \int_0^L \sin \dfrac{\pi x}{L} \, dx$

$\displaystyle A = \dfrac{aL}{\pi} \int_0^L \left( \sin \dfrac{\pi x}{L} \right)\left( \dfrac{\pi}{L} \, dx \right)$

$A = \dfrac{aL}{\pi} \left[ -\cos \dfrac{\pi x}{L} \right]_0^L$

$A = -\dfrac{aL}{\pi} \left[ \cos \pi - \cos 0 \right]$

$A = -\dfrac{aL}{\pi} \left[ -2 \right]$

$A = \dfrac{2aL}{\pi}$

Location of centroid

$\displaystyle A \, \bar{y} = \int_a^b y_c \, dA$

$\displaystyle \dfrac{2aL}{\pi} \, \bar{y} = \int_0^L (\frac{1}{2}y)(y \, dx)$

$\displaystyle \dfrac{2aL}{\pi} \, \bar{y} = \frac{1}{2}\int_0^L y^2 \, dx$

$\displaystyle \dfrac{2aL}{\pi} \, \bar{y} = \frac{1}{2}\int_0^L \left( a \sin \dfrac{\pi x}{L} \right)^2 \, dx$

$\displaystyle \dfrac{2aL}{\pi} \, \bar{y} = \dfrac{a^2}{2}\int_0^L \sin^2 \dfrac{\pi x}{L} \, dx$

From

$\cos 2\theta = 1 - 2\sin^2 \theta$
$\sin^2 \theta = \frac{1}{2}(1 - \cos 2\theta)$

Assign $\theta = \dfrac{\pi x}{L}$

Thus,

$\displaystyle \dfrac{2aL}{\pi} \, \bar{y} = \dfrac{a^2}{2}\int_0^L \frac{1}{2} \left( 1 - \cos \dfrac{2\pi x}{L} \right) \, dx$

$\dfrac{2aL}{\pi} \, \bar{y} = \dfrac{a^2}{4}\left[ x - \dfrac{L}{2\pi}\sin \dfrac{2\pi x}{L} \right]_0^L$

$\dfrac{2aL}{\pi} \, \bar{y} = \dfrac{a^2}{4}\left[ \left( L - \dfrac{L}{2\pi}\sin 2\pi \right) - \left( 0 - \dfrac{L}{2\pi}\sin 0 \right) \right]$

$\dfrac{2aL}{\pi} \, \bar{y} = \dfrac{a^2}{4}\left[ L \right]$

$\dfrac{2aL}{\pi} \, \bar{y} = \dfrac{a^2L}{4}$

$\bar{y} = \dfrac{\pi a}{8}$ *answer*