We will use this formula:
M1C1ΔT1 = M2C2ΔT2
when M1 mass of sample 1 = 31 g
C1 for water = 4.184
and ΔT1 = (Tf- 290)
and M2 of sample 2 = 47 g
C2 for water = 4.184
and ΔT2 = (340 - Tf)
so by substitution, we can get Tf (the final temperature):
31 g * 4.184 * ( Tf - 290 k ) = 47g * 4.184 * (340 - Tf)
∴Tf ( the final temperature) = 320 K