The total ratio of goats and sheep on the farm is 5+7 = <<5+7=12>>12
The fraction that represents goats from the total ratio is 5/12, and since there are 360 goats and sheep on the farm, the number of goats is 5/12*360= <<5/12*360=150>>150
The number of sheep on Mr. Mathews's farm is 360-150 = <<360-150=210>>210.
Mr. Mathews sold 1/2*150 = <<1/2*150=75>>75 goats.
If each goat went for $40, the total amount of money Mr. Mathews made from the sale of his goats is 75*$40 = $<<75*40=3000>>3000
He also sold 2/3*210 = <<2/3*210=140>>140 of the total sheep on his farm.
The income from the sale of the sheep is 140*$30=$<<140*30=4200>>4200
From the sale of goats and sheep, Mr. Mathews made $4200+$3000 = $8600
#### 7200