The center of a group of order $3^2q$ has order $1$ or $3$. this is a question from a brazillian book, Paulo A. Martin's "Grupos, Corpos e Teoria de Galois" (portuguese for "Groups, fields and Galois Theory" (The actual word field translate as "Campo", but in the math context, the term used is "Corpo", wich means "body")).
It starts with the classic old question that was answered many times in this site, in this link, only changing $p$ for $3$.
The next part is to prove the following:

Let $G$ be a group of order $3^2q$, with $q$ prime, $q>3$. If $q\equiv 1\pmod3$ and $G$ is not abelian show that $|Z(G)|=1 \ \text{or} \ 3$.

Ok, here I start to work. Right, if $G$ is not abelian, then $G / Z(G)$ is not cyclic, so, $|G / Z(G)|$ is not a prime and as $ |Z(G)|$ divides $|G|$, $|Z(G)| = 1, 3 \ \text{or} \ q$. The problem here is show that we can't have $|Z(G)|=q$. But how? How can I prove this? Is this right? I got some things, like $n_{q}=1$ and $n_{3}=1 \ \text{or} \ q$ but I don't know if this is usefull.
I appreciate any help! Thanks in advance for everyone who read!
 A: If $|Z(G)|=1$, then we are done.
If $q$ divides $|Z(G)|$, then Sylow-$q$ will be central subgroup, so $G$ is direct product of Sylow-$3$ and Sylow-$q$ (why?), so it will be abelian.
If $q$ does not divide $|Z(G)|$ but $3$ divides $|Z(G)|$, we try to show, $3^2$ does not divide $|Z(G)|$. If this is not the case, then taking $K$ to be a central subgroup of order $3^2$, we get that $G/K$ is cyclic, so $G$ is abelian.
Similarly, we can show that if $3q$ divides $|Z(G)|$ then $G$ is abelian.
This covers all the basic and sufficient cases.
A: This argument doesn't use any Sylow theorem.
In principle (Lagrange), nonabelian $G$ with $|G|=3^2q$ can have center of order any among $1,3,3^2,q,3q$. Hereafter, $\mathcal{K}:=\{\text{noncentral conjugacy classes of}\space G\}$, $k:=\#\mathcal{K}$ and $\mathcal{R}$ is a complete set of representatives of the elements of $\mathcal{K}$. Note that $\mathcal{K}\ne\emptyset$ by assumption on $G$.

*

*If $|Z(G)|=3^2$, then for every noncentral $g\in G$, $|C_G(g)|=3^2$, because $3^2\nmid q$; therefore, all the noncentral conjugacy classes comprise exactly $q$ elements and their (disjoint) union must count $|G|-|Z(G)|=3^2q-3^2=3^2(q-1)$ elements: contradiction, because $q\nmid 3^2(q-1)$.

*If $|Z(G)|=q$, then, for every noncentral $g\in G$, $|C_G(g)|=3^{\alpha(g)}q$, where $\alpha(g)\in\{0,1\}$. The Class Equation, $\sum_{g\in\mathcal{R}}\frac{|G|}{|C_G(g)|}=|G|-|Z(G)|$, then yields:
$$3(3l_0+l_1)=8q \tag 1$$
where $l_0+l_1=k$. By taking "$\text{mod 3}$" both sides of $(1)$, we get: $8q\equiv 0\pmod 3$, in contradiction with the assumption $q\equiv 1\pmod 3$.

*If $|Z(G)|=3q$, then $G/Z(G)$ is cyclic, whence $G$ is abelian: contradiction.

