Question 903287
I divided it into three periods
David was the only investors for 6 months so he gets all the profit for that period

10000 for 12 months
15000 for 6 months 1/2
20000 for 4 months 1/3

10000  for 6 months 6/12 1450 d 1/2 of the year

john and david were the only investors for 2 months  1/6 of the year
10000+15000 for 2 months 2/12 483.33
david had 2/5 and john had 3/5 of the investment
d 10/25=2/5 96.66*2 193.33
j 15/25=3/5 96.66*3 290.00

all three were investors for the last four months  1/3 of the year

10000+15000+20000 for 4/12  966.67 
proportion of the investments
d 10/45 j 15/45 p 20/45

21.48*10 214.81 d 
21.48*15 322.22 j
21.48*20 429.63 p


david =1450+193.33+214.81=$1858.14
john=290+322.22=$612.22
peter =$429.63

That is how I see it.