A scattering-matrix approach to the eigenenergies of quantum dots