An electric motor is connected to a battery. The current flows through brushes to a commutator ring, which is attached to an electromagnet turning through a permanent magnetic field.

What is the purpose of the commutator ring?

A. It periodically reverses the current flow through the electromagnet.

B. It turns the electromagnet in the opposite direction.

C. It allows mechanical energy to be converted into electrical energy.

D. It keeps the electromagnet from losing its magnetism.