The first train took 5 hours because 200 / 40 = <<200/40=5>>5
The second train took 3 hours because because 240 / 80 = <<240/80=3>>3
The total time was 8 hours because 5 + 3 = <<5+3=8>>8
The average time was 4 hours because 8 / 2 = <<8/2=4>>4
#### 4