The formula of density is mass / volume.
So, the volume is equal to the area of the cube by the total height, so the area of the cube is 3x3= 9, and this result multiplied by the height, 9x3 = 27.
Following the formula of density, we have 216 g / 27 cm^3, the result is 8 g/cm^3.
Hope you undestand my procedure XD