The idea here is that you can use a substance's density as a conversion factor to go from grams to volume and vice versa.
Simply put, if you know the density of a substance, you can use it to determine the volume of a given mass of said substance. Likewise, if you are given the volume of the substance, you can use its density to determine the mass of the sample.
You're dealing with a rectangular prism, which means that you can use its dimensions to find its volume
#color(blue)(|bar(ul(color(white)(a/a)V = "length" xx "height" xx "width"color(white)(a/a)|)))#
In your case, you will have
#V = "3.00 cm" xx "2.50 cm" xx "1.80 cm" = "13.5 cm"^3#
So, this substance is said to have a density of
Use this as a conversion factor to get the mass that will occupy a volume of
#13.5 color(red)(cancel(color(black)("cm"^3))) * overbrace("3.14 g"/(1color(red)(cancel(color(black)("cm"^3)))))^(color(purple)("the given density")) = color(green)(|bar(ul(color(white)(a/a)"42.4 g"color(white)(a/a)|)))#
The answer is rounded to three sig figs.