What is your body trying to do when you are either shivering or sweating?

Shivering warms the body by increasing metabolism, and sweating cools the body by the effects of evaporation of the moisture on the skin.