allocable to such period as— (A) a qualified scholarship which is excludable from gross income under section 117, (B) an educational assistance allowance under chapter 30, 31, 32, 34, or 35 of title 38, United States Code, or under chapter 1606 of title 10, United States Code, and (C) a payment (other than a gift, bequest, devise, or inheritance within the meaning of section 102(a)) for such individual's educational expenses, or attributable to such individual's enrollment at an eligible educational institution, which is excludable from gross income under any law of the United States. (3) Treatment of expenses paid by dependent If an individual is a dependent of another taxpayer for a taxable year beginning in the calendar year in which such individuals taxable year begins— (A) no credit shall be allowed under subsection (a) to such individual for such individual’s taxable year, and (B) qualified tuition and related expenses paid by such individual during such individual’s taxable year shall be treated for purposes of this section as paid by such other taxpayer. (4) Treatment of certain prepayments If qualified tuition and related expenses are paid by the taxpayer during a taxable year for an academic period which begins during the first 3 months following such taxable year, such academic period shall be treated for purposes of this section as beginning during such taxable year. (5) Denial of double benefit No credit shall be allowed under this section for any amount for which a deduction is allowed under any other provision of this chapter. (6) No credit for married individuals filing separate returns If the taxpayer is a married individual (within the meaning of section 7703), this section shall apply only if the taxpayer and the taxpayer’s spouse file a joint return for the taxable year. (7) Nonresident aliens If the taxpayer is a nonresident alien individual for any portion of the taxable year, this section shall apply only if such individual is treated as a resident alien of the United States for purposes