The table below shows the surface temperature ranges associated with a given Spectral Class (temperatures are, of course, given in Kelvins):
Spectral Class and Spectral Type
A star's Spectral Type, on the other hand, is a numerical value indicating where within the given range a star's surface temperature falls.
For instance, the Sun is designated as a G2 star: Spectral Class G, Spectral Type 2.
Its Spectral Class of G means that it has a surface temperature is in the range between 5200K and 6000K.
Within each Spectral Class are ten Spectral Types, ranging from zero to nine. The zero type is at the high end of the temperature range, and the nine type is at the low end of the temperature range.
The Spectral Type of the Sun having a value of 2 means that it falls into the third subdivision of surface temperatures below the highest for Spectral Class G; specifically, the Sun's surface temperature is ~5822.22 K (more on this next).
Calculating Spectral Class from Known Surface Temperature
For example, the Sun's surface temperature is listed in most sources as about 5800K. (The actual figure—by calculation—is closer to 5822.22 K ... more on this below, keep reading).
If we didn't already know that it's a G-class star, we could consult the first table and find the range into which the temperature 5800K falls and see that it is between 5200K and 6000K, telling us that the Sun is a G-class star.
If we then run the equation for G-class stars, using the 5800K value for the Sun's surface temperature, we get a Spectral Type of 2.25:
Calculating Surface Temperature from Known Spectral Class and Type
If we take the Spectral Type for the Sun to be 2, as specified in most sources, and run this value through the equation for Spectral Class G in the above table:
As another example, the star Zeta Tucanae is listed  as having a Spectral Class/Type of F9.5. Using the appropriate equation: