In a class of $40$ students, $18$ said they liked apple pie, $15$ said they liked chocolate cake, and $12$ said they did not like either. How many students in the class liked both?
40-12=28 people had to like some flavor.
Let y be the people who like both...
Thus, we have
Thus, there are five(5) students in the classroom who liked both apple pie and chocolate cake.