If your class is composed by [tex]n[/tex] students, then we have to multiply the $2 donation by the number of students, so the total donation is [tex]2n[/tex] dollars.
Let [tex]n[/tex] be the amount of dollars in your paycheck. Half that quantity is [tex]\frac{n}{2}[/tex]. If you add 6 extra dollars, the total amount will be
[tex]\dfrac{n}{2}+6[/tex]