Sam has 18 coins in his pocket that are either quarters or nickels. The total value of these coins is $3.90.

Let q represent the number of quarters and n represent the number of nickels. The following system of equations represents this situation:

q+n=18

0.25q+0.05n=3.90

How many quarters and nickels does Sam have?