Energies and moments of giant resonances for isoscalar monopole and quadrupole excitations: A sum-rule approach