The simplest way to calculate the weight of a cube is to weigh it on a scale. However, the basic properties of a cube allow for the calculation of its mass by using the measurements of its volume and its density. The mass of an object is indistinguishable from its weight in a normal environment because the exertion of the force of gravity on the object is inferred in the calculations. Calculating a cube's weight can also be as simple as a few steps of multiplication.
Measure one side of the cube. A cube is defined as having equal length, width and height. Measuring one side will result in the measurement of each of these parameters. For the example, the length of one side is 5 cm.
Calculate the measurement of a side to the third power, which is the volume. The actual formula for volume for a cube is the length multiplied by the width and then multiplied by the height. Since all three measurements are the same, the formula results in the measurement of one side cubed. For the example, 5^3 is 125 cm^3.
Multiply the volume by the known density, which is the mass per volume. The formula for density is density equals mass, or weight, over volume. Rearranging that formula results in mass equals density multiplied by volume. For the example the density of the cube is 10 grams per cm^3. Multiplying that by 125 cm^3 equals 1,250 grams or 1.25 kilograms.
TL;DR (Too Long; Didn't Read)
To take into account the weight of the object with a different gravity than the Earth's, multiply the mass by the force of gravity.