In this example, we calculate the porosity with the equation:
Φ = (V_bulk - V_grain) / V_bulk
The code prompts the user to enter the bulk volume and the grain volume, computes the porosity, and then prints the value along with a percentage representation.
Try running the code below, enter some values, and observe how the porosity changes.