I cant figure out how to make a function that correctly solves the max height of a parabola

I know height = distance * tan(angle) - (gravity * distance^2) /2 *( speed * cos(angle))^2

I try to put this in and I get like 1.2 trillion

I think im doing it right....

anyone mind helping me figure this out?

Distance = 3831.57

Angle = 35

Gravity = 9.81

Speed = 200

after inputing these in the the formula the anwser is suppose to be like 670 but I dont know how to do it let alone put it in c++