v = speed of the source of sound or the train towards the listener or switchman = 40 m/s
V = actual speed of sound = 340 m/s
f = actual frequency of sound as emitted from source or the train = 1000 Hz
f' = frequency as observed by the listener or by switchman = ?
Using Doppler's law , frequency observed by a listener from a source moving towards it is given as
f' = V f /(V - v)
inserting the values
f' = 340 x 1000 /(340 - 40)
f' = 340 x 1000/300