le'ts take a peek at the ages, 9, 6 and 5, so their ratio will be in the order of 9:6:5, what we firstly do is divide the total by that many pieces, namely 100 ÷ (9+6+5) and then distribute accordingly.
[tex]\stackrel{John}{9}~~:~~\stackrel{Koffi}{6}~~:~~\stackrel{Gary}{5}\quad \implies \quad \stackrel{John}{9\cdot \frac{100}{9+6+5}}~~:~~\stackrel{Koffi}{6\cdot \frac{100}{9+6+5}}~~:~~\stackrel{Gary}{5\cdot \frac{100}{9+6+5}} \\\\\\ \stackrel{John}{9\cdot 5}~~:~~\stackrel{Koffi}{6\cdot 5}~~:~~\stackrel{Gary}{5\cdot 5}\qquad \implies \qquad \stackrel{John}{45}~~:~~\stackrel{Koffi}{30}~~:~~\stackrel{Gary}{25}[/tex]