Application of a dielectric function to the exchange energy and specific heat of a two-dimensional electron gas