An electric generator is an engine that is a machine for converting mechanical energy into electrical energy.