The bond with six months left to maturity has a semiannual discount rate of 0.04 / 2 = 0.02 or 4% on an annual bond equivalent yield (BEY) basis. Since the bond will only make a single payment of 102 in six months, the YTM is the spot rate for cash flows to be received six months from now.
The one-year bond will make two payments, one in six months of 2.50 and one in one year of 102.50. We can solve for the one-year spot rate in the equation:

where S1.0 is the annualized 1-year spot rate.
Solving we get: S1.0 = 5.01256%.
Using the 6-month and 1-year spot rates, we can use the same approach to find the 18-month spot rate from the equation:

where S1.5 is the annualized 18-month spot rate.
Solving we get: S1.5 = 6.04072%.