I know that solutions to this exercise can be found quite easily but I have tried to solve it on my own and I'm stuck on the last case. I would be glad if someone could tell me if this is correct and how to continue:
The only case remaining is that $G$ has an element of order 4, say $g$. Then $\langle g\rangle$ is a normal subgroup.
Let's assume that there is an element $h$ of order 2 which is not $g^2$. Then $\langle h\rangle\cap\langle g\rangle=\{e\}$ and $\langle h\rangle\langle g\rangle=G$, so $G=\langle g\rangle\rtimes\langle h\rangle\cong\mathbb Z_4\rtimes\mathbb Z_2\cong D_4$.
Let's assume there is no such element $h$. So the only element of order 2 in $G$ is $g^2$. But then $G$ has 6 elements of order 4. Can I conclude that $G\cong Q_8$ from that when knowing that $Q_8$ has 6 elements of order 4 and one each of order 1 and 2? I'm not sure if having elements with the same order yields an isomorphism.
Edit: Maybe my question can be reduced to: Are there groups of the same order with all elements having identical order that are not isomorphic?