One thing to not is that 40k is just the sticker price. Only 3-10% of students pay that price at any given school. Why the sticker price? To make the school seem more valuable to the students and make the students seem overjoyed when they get a 15k grant/scholarship a year like I did. 25k is still a lot, but it's not 40k.
Really good NPR Planet Money podcast on this - http://www.npr.org/blogs/money/2012/05/11/152511771/the-real...