To determine the distance Mr. X had to cover, we need to analyze the information given and use it to set up an equation using time and speed relationships.
1. Identify and define the variables:
- Let \(\( d \)\) be the distance Mr. X had to cover (in kilometers).
- \(\( v_w = 8 \)\) km/hr is the walking speed.
- \(\( v_c = 12 \)\) km/hr is the cycling speed.
- \(\( t_w \)\) is the time taken to walk the distance.
- \(\( t_c \)\) is the time taken to cycle the distance.
- The required time to catch the bus if everything was perfect is \(\( t \)\).
2. Convert the time differences from minutes to hours:
- 5 minutes late means \(\( \frac{5}{60} \)\) hours.
- 4 minutes early means \(\( \frac{4}{60} \)\) hours.
3. Express the time taken to cover the distance through walking and cycling:
- Time taken walking, \(\( t_w \)\): \(\( t_w = \frac{d}{v_w} = \frac{d}{8} \)\)
- Time taken cycling, \(\( t_c \)\): \(\( t_c = \frac{d}{v_c} = \frac{d}{12} \)\)
4. Set up the equations based on the problem statement:
- Mr. X misses the bus by 5 minutes when walking: \(\( \frac{d}{8} = t + \frac{5}{60} \)\)
- Mr. X arrives 4 minutes early when cycling: \(\( \frac{d}{12} = t - \frac{4}{60} \)\)
5. Isolate the time variable \(\( t \)\) in both equations:
- Walking equation: \(\( t = \frac{d}{8} - \frac{5}{60} \)\)
- Cycling equation: \(\( t = \frac{d}{12} + \frac{4}{60} \)\)
6. Set the equations equal to each other since they both represent the same \(\( t \)\):
\(\[
\frac{d}{8} - \frac{5}{60} = \frac{d}{12} + \frac{4}{60}
\]\)
7. Clear the equation by getting rid of the fractions:
To simplify, multiply every term by 60 (the least common multiple of 8, 12, and 60):
\(\[
60 \left( \frac{d}{8} \right) - 60 \left( \frac{5}{60} \right) = 60 \left( \frac{d}{12} \right) + 60 \left( \frac{4}{60} \right)
\]\)
\(\[
7.5d - 5 = 5d + 4
\]\)
8. Solve for \(\( d \)\) by combining and simplifying:
\(\[
7.5d - 5d = 4 + 5
\]\)
\(\[
2.5d = 9
\]\)
\(\[
d = \frac{9}{2.5}
\]\)
\(\[
d = 3.6
\]\)
Thus, the distance Mr. X had to cover is \(\( \boxed{3.6 \text{ km}} \)\).