We compute the ground-state energy of atoms and quantum dots with a large number N of electrons. Both systems are described by a nonrelativistic Hamiltonian of electrons in a d-dimensional space. The electrons interact via the Coulomb potential. In the case of atoms (d = 3), the electrons are attracted by the nucleus via the Coulomb potential. In the case of quantum dots (d = 2), the electrons are confined by an external potential, whose shape can be varied. We show that the dominant terms of the ground-state energy are those given by a semiclassical Hartree-exchange energy, whose N -> infinity limit corresponds to Thomas-Fermi theory. This semiclassical Hartree-exchange theory creates oscillations in the ground-state energy as a function of N. These oscillations reflect the dynamics of a classical particle moving in the presence of the Thomas-Fermi potential. The dynamics is regular for atoms and some dots, but in general in the case of dots, the motion contains a chaotic component. We compute the correlation effects. They appear at the order N ln N for atoms, in agreement with available data. For dots, they appear at the order N.