The time period of a simple harmonic motion (SHM) is given by:
\[
T = 2\pi \sqrt{\frac{m}{k}},
\]
where:
\( T \) is the time period,
\( m \) is the mass,
\( k \) is the spring constant.
Step 1: Initial time period.
The time period with mass \( m \) is:
\[
T_1 = 2 = 2\pi \sqrt{\frac{m}{k}}.
\]
Squaring both sides:
\[
T_1^2 = \frac{4\pi^2 m}{k}.
\]
Rearranging for \( m \):
\[
m = \frac{k T_1^2}{4\pi^2}.
\]
Step 2: New time period with added mass.
The new time period is \( T_2 = 5 \, \mathrm{s} \), and the total mass becomes \( m + 0.04 \):
\[
T_2^2 = \frac{4\pi^2 (m + 0.04)}{k}.
\]
Rearranging:
\[
m + 0.04 = \frac{k T_2^2}{4\pi^2}.
\]
Step 3: Subtract initial from new equation.
From the two equations:
\[
\frac{k T_2^2}{4\pi^2} - \frac{k T_1^2}{4\pi^2} = 0.04.
\]
Factorize:
\[
\frac{k}{4\pi^2} (T_2^2 - T_1^2) = 0.04.
\]
Substitute \( T_1 = 2 \, \mathrm{s} \) and \( T_2 = 5 \, \mathrm{s} \):
\[
\frac{k}{4\pi^2} (5^2 - 2^2) = 0.04.
\]
Simplify:
\[
\frac{k}{4\pi^2} \cdot (25 - 4) = 0.04.
\]
\[
\frac{k}{4\pi^2} \cdot 21 = 0.04.
\]
Solve for \( \frac{k}{4\pi^2} \):
\[
\frac{k}{4\pi^2} = \frac{0.04}{21}.
\]
Step 4: Substitute back to find \( m \).
Using the expression for \( m \):
\[
m = \frac{k T_1^2}{4\pi^2}.
\]
Substitute \( T_1 = 2 \, \mathrm{s} \):
\[
m = \left(\frac{0.04}{21}\right) \cdot 4.
\]
Simplify:
\[
m = \frac{0.04 \cdot 4}{21} = 0.00761 \, \mathrm{kg}.
\]
Convert to grams:
\[
m = 7.64 \, \mathrm{g}.
\]
Thus, the mass is \( \mathbf{7.64 \, \mathrm{g}} \).