She can't make you do anything, however if it is a distraction to the class then yeah. I'm assuming it's your math teacher. she can make you take off anything on your head though
first the drink cost 3 dollars so take that away from the total and you have 40. then do 40 divided by the 8 candy bars and you get 5. Which means that each candy bar cost 5 dollars