Hint. Let $G$ be a group in which $\mathbb{Z}$ is a subgroup of index $2$.
$\hspace{10pt}\text{S}{\small \text{TEP}}\text{ I}.\hspace{8pt}$ Prove that subgroups of index $2$ are necessarily
normal.
$\hspace{10pt}\text{S}{\small \text{TEP}}\text{ II}.\hspace{5pt}$ This means that $G$ acts by automorphisms on $\mathbb{Z}$. What are the automorphisms of $\mathbb{Z}$?
$\hspace{10pt}\text{S}{\small \text{TEP}}\text{ III}.\hspace{2pt}$ If $G=\mathbb{Z}K$, what are the options for $K$? Relate this to the different options in $\text{II}$.
Note. Be careful in $\text{S}{\small \text{TEP}}\text{ III}$ to consider the case where the extension is nonsplit (that is, $G$ is not a semidirect product of the form $\mathbb{Z}\rtimes K$). If you get stuck here, try constructing group presentations.