You're good up through this step, with just a minor correction. H is a function of the variable,
d, so you need to integrate with respect to
d, not
x. Here, I've written Delta d instead of dd to prevent confusion:
\(\displaystyle \displaystyle y_{avg}=\frac{1}{4-0}\int _0^4\left(4d-d^2\right)\Delta d\)
After that, it goes sideways. It looks like in the next step, you tried to pull out a 4 from the function h(d). That can be done, except that you have to pull it out of
both terms. So if you did that, you'd have:
\(\displaystyle \displaystyle y_{avg}=\frac{4}{4}\int _0^4\left(d-\frac{1}{4}d^2\right)\Delta d\)
But then it seems to go even further off the rails, because you evaluate the indefinite integral, but somehow end up with \(\displaystyle d \Delta d\) inside the braces? And at the step after that, you have re-inserted a 4 into the braces, seemingly from nowhere.
You're using the correct method, but I think you just dropped the ball due to being in a hurry. I know full well the errors that creep in when I rush a problem. I've ended up with nonsense like (-2)*3 = 5 while working a problem, and so of course the whole thing was wrong from there on. So, go back and give it another try when you have time to dedicate to it, and you'll probably get it right.