In this particular type of question we first need to draw a diagram for a clear picture of the scenario. We need to observe the triangles which are formed in the question and then use the formula of tan$\theta $ to find the required equations and find the distance the boy travelled.
Complete step-by-step answer:
Height of the boy = AB=CD= EQ = 1.5 m
Let distance (BD) covered by him be x
Now BD=AC=x
Let the distance of the building from the point where he stopped be y .
$ \Rightarrow $ DQ=CE= y
In the figure, PE=30-1.5=28.5m which is the distance of the top of the building to the eye (head) level of the boy.
Now the angles from where he started and where he stopped walking are$30^\circ {\text{ and 60}}^\circ $ respectively .
On observing triangles PAE and PCE , we get
\[ In{\text{ }}\vartriangle {\text{PAE,}} \]
\[ {\text{tan30}}^\circ {\text{ = }}\dfrac{{PE}}{{AE}} \]
\[ \Rightarrow \dfrac{1}{{\sqrt 3 }} = \dfrac{{28.5}}{{x + y}}{\text{ }} \]
\[ \Rightarrow {\text{x + y = 28}}{\text{.5}}\sqrt 3 \left( i \right) \]
\[ In{\text{ }}\vartriangle {\text{PCE,}} \]
\[ \tan 60^\circ = \dfrac{{PE}}{{CE}} \]
\[ \Rightarrow \sqrt 3 = \dfrac{{28.5}}{y} \]
\[ \Rightarrow y = \dfrac{{28.5}}{{\sqrt 3 }} \]
Put in (i)
We get,
$x + \dfrac{{28.5}}{{\sqrt 3 }} = 28.5\sqrt 3 $
$x = 28.5\sqrt 3 - \dfrac{{28.5}}{{\sqrt 3 }} = \dfrac{{28.5\sqrt 3 \times \sqrt 3 - 28.5}}{{\sqrt 3 }} = \dfrac{{85.5 - 28.5}}{{\sqrt 3 }} = \dfrac{{57}}{{\sqrt 3 }}$
Rationalize,
$\dfrac{{57}}{{\sqrt 3 }} \times \dfrac{{\sqrt 3 }}{{\sqrt 3 }} = \dfrac{{57\sqrt 3 }}{3} = 19\sqrt 3 $ m
Thus we get x = $19\sqrt 3 m$ which is the distance he walked towards the building.
Note- It is important to note that in this particular type of question we need to recall the formula for tan$\theta $ to find the desired answer . Remember to observe the diagram carefully and recall the difference between angle of elevation and angle of depression as many students confuse between them . Also rationalize the answer to remove any radical from the base .