Let x denote the price of a book.
Then the price of a CD is given by 3x.
You bought three books and two CDs, so the total you spent is 3x + 2(3x) = 9x. You are given that this total equals 18. So 9x = 18, which means that x = 2.
Thus the price of a book is $2 and the price of a CD is $6.