The guiding principle is the Law of Conservation of Energy: the sum of all the energy changes must add up to zero.
EXAMPLE
What is the final temperature if 10.0 kg of water at 10.0 °C is mixed with 2.00 kg of water at 100 °C? The specific heat capacity of water is #"4.184 kJ·°C"^"-1""kg"^"-1"#
Solution
The formula for the heat #q# gained or lost by a substance is
#color(blue)(bar(ul(|color(white)(a/a)q = mcΔTcolor(white)(a/a)|)))" "#
where
#m# is the mass of the substance.
#c# is its specific heat capacity.
#ΔT = T_"f" - T_"i"# is the change in temperature.
In this problem, there are two heat flows.
#"Heat gained by cold water + Heat lost by hot water" = 0#
#q_1 + q_2 = 0#
#m_1c_1ΔT_1 + m_2c_2ΔT_2 = 0#
In this problem,
#m_1 = "10.0 kg";color(white)(mmm) m_2 = "2.00 kg"#
#color(white)(mm)c_1 = c_2 = "4.184 kJ·K"^"-1""kg"^"-1"#
#ΔT_1 = T_"f"color(white)(l) "- 10.0 °C"; ΔT_2 = T_"f" color(white)(l)"- 100.0 °C"#
#m_1color(red)(cancel(color(black)(c_1)))ΔT_1 + m_2color(red)(cancel(color(black)(c_2)))ΔT_2 = 0#
Since #c_1 = c_2#, we can cancel them from the equation. This gives
#m_1ΔT_1 + m_2ΔT_2 = 0#
#10.0 color(red)(cancel(color(black)("kg")))(T_"f"color(white)(l) "- 10.0 °C") + 2.00 color(red)(cancel(color(black)("kg")))(T_"f" color(white)(l)"- 100.0 °C"#
#10.0T_"f" - "100 °C" + 2.00T_"f" - "200 °C" =0#
#12.0 T_"f" = "300 °C"#
#T_"f" = "300 °C"/12.0 = "25.0 °C"#