Congratulations to the following members for their correct solutions:
Solutions from Ackbach and Pranav are explained in detail below:
Solution from Ackbach:
All the coefficients of the polynomial are real. Therefore, any possible complex roots would have to come in complex conjugate pairs. But this is impossible, because we are to impose the condition that there are exactly two distinct real roots. Therefore, one of the real roots must be repeated. Given the pattern of the given cubic, we will set
This sets up a system of three equations in three unknowns, by equating coefficients of like powers:
From the first equation, we have $a=-2b$. Plugging this into the second two equations yields
Next, we have
$$2b^3=-2(-3b^2+4) \implies b^3-3b^2+4=0.$$
This cubic has a solution $b=2$; dividing out the factor $b-2$ yields the depressed quadratic $b^2-b-2=(b+1)(b-2)$. Hence, the distinct solutions are $b=-1, 2$. The corresponding $k$ values are $k=-3, -12$.
Solution from Pranav:
Let the two distinct roots be $a$ and $b$, then
x^3+kx-2(k+4) =& (x-a)^2(x-b) \\ =& x^3-(2a+b)x^2+(2ab+a^2)x-a^2b\\
Comparing the coefficient of $x^2$ on both sides gives $0=2a+b \Rightarrow b=-2a$.
Comparing the coefficient of $x$ on both sides gives $k=2ab+a^2 \Rightarrow k=-3a^2 \,\,\,(\because b=-2a)$ .
Comparing the constant terms gives $2(k+4)=a^2b \Rightarrow 2(-3a^2+4)=-2a^3 \Rightarrow a^3-3a^2+4=0$.
The above cubic has $a=-1$ as one of it roots. Dividing the cubic by $a+1$ gives $a^2-4a+4=0 \Rightarrow (a-2)^2=0 \Rightarrow a=2$.
The values of $k$ can be found using $k=-3a^2$. Hence the values of $k$ are $-3$ and $-12$.