Let p be the prize of a pen and m the prize of a mechanical pencils. If you buy six pens and one mechanical pencil, you spend 6p+m. We know that this equals 9, because you get 1$ change from a 10$ bill.
Similarly, if you buy four pens and two mechanical pencils, you spend 4p+2m, which is 8$, because now you get a $2 change. Put these equation together in a system:

Now, if you multiply the first equation by 2, the system becomes

Subtract the second equation from the first:

Plug this value into the first equation to get

Factoring out the 1/2 (that is the coefficient of the variable) would require you to divide the equation by one half, which is the same as multiplying by two. After doing this, the answer can be expressed as:
1/2 (d+12)
Angle B corresponds to angle Y