Get your taxes done using TurboTax

My earned income was $18,000 and I had $18,000 in capital gains.  I thought that there would be 0 tax on capital gains because my total income is under $40,000.  But I am being taxed on $36,000, not $18,000.  Is this a bug in TurboTax.  Why isnt the capital gain being taxed at 0%?