If there are 24 people and each of them will eat 2 cups of ice cream, then there will be 48 cups of ice cream in total.
We know that 1 gallon is equivalent to 16 cups, so we form the following proportion
[tex]\frac{1\text{gallon}}{x}=\frac{16\text{cups}}{48\text{cups}}[/tex]Let's solve for x
[tex]\begin{gathered} x=\frac{48}{16}\text{gallons} \\ x=3\text{gallons} \end{gathered}[/tex]