Extinction, scattering and absorption of electromagnetic waves in the coupled-dipole approximation