The reason things float or sink in water is due to the object's or material's density. The density of water is 1.0 grams per cubic centimeter at 68 degrees Fahrenheit. Objects that have a lower density than water will float, while objects or materials that have greater densities than water will sink.
If the mass and volume of different solid materials are known, then the density of these materials can be determined by using the formula "Density = mass/Volume." By comparing the densities of different materials, it is possible to know whether or not they will sink or float in water.
Similarly, fluids with different densities can be placed together in a container. By examining the different fluid layers formed in the container, the fluid with the greater density can be determined. For example, if oil is added to a glass of water, the oil will float to the top because it has a lower density than water.