$\space$Let $p$ be a prime number and let $G$ be a group of order $p^4$ such that $|Z(G)|=p^2$. Calculate the number of conjugacy classes of $G$. Since $Z(G) \neq G$, then $G$ is not abelian.
I'll write what I've done so far:
I suppose I must apply the class equation here. I consider the action of $G$ on itself by conjugation. Then $$(1) \space \space G=Z(G)\coprod(\coprod_{i=1}^n O_{x_i})$$ where $x_i$ is a representative of the orbits of order greater than $1$. It is easy to find a bijection between $\mathcal O_x$ and the quotient $G/G_x$ where $G_x$ is the stabilizer. From here it follows $|\mathcal O_x|=\frac{|G|}{|G_x|}=[G:G_x]$. In this particular action, we have that the centralizer, $C(x)$, is equal to $G_x$. So $(1)$ becomes $$(2) \space \space G=Z(G)+\sum_{i=1}^n [G:C(x_i)]$$.
From $(2)$ and the the hypothesis given in the statement we have $$(3)\space \space \space \space p^4-p^2=p^2(p^2-1)=\sum_{i=1}^n [G:C(x_i)] $$
How can I relate the number of cosets of each quotient $G/C(x)$ to the conjugacy classes?
Any help would be appreciated
Let $x \in G$, and assume $x \notin Z(G)$. Then certainly $Z(G) \subsetneq C_G(x) \subsetneq G$. Since index$[G:Z(G)]=p^2$, it follows that index$[G:C_G(x)]=|Cl_G(x)|=p$. Hence all non-central elements have a conjugacy class of cardinality $p$. This gives you $k(G)=p^2+\frac{p^2(p^2-1)}{p}= p^3+p^2-p.$