A compass is wrapped in a coil of wire that is connected to a switch and battery. Which statement best explains why the compass needle turns when the switch is closed?