when in doubt about a function, I always check the units.

For instance, your formula:

mass_amount = mass*height*width*length;

would produce:

mass_amount = kilograms*meters*meters*meters

or

mass_amount = kg*m^3 which is not a unit of mass

just something to always check when you are not sure. Unit analysis is a very powerful thing.