Heat required to cool water to level of ice = mCx1
where C is specific heat of water
Heat required to convert water into ice = mL
where L is latent heat of fusion
Heat required to cool ice from water = mC' x t
where t is final temp of mixture
Heat required to raise temp of ice = m C' x (40-t)
where C' is specific heat of ice
mC + mL + mC't = mC'(40-t)
m = 1 so it cancels
place values of C and C' and calculate t