To solve, I would try and setup a ratio between the smaller triangle with the corresponding side lengths with the bigger triangle.
You could say 4x+4/30 = 5x+7/40
The reason we can assume this is because both of the triangles have the same angle so the ratio must be equal.
Hope this helps!