 <p>You are doing integer division! Since <code>totaloccupied</code> is smaller than <code>totaldrive</code>, the division of both gives the answer <code>0</code>. You should convert to double first:</p> <pre><code>double percentageUsed = 100.0 * totalOccupied / totalDrive; </code></pre> <p>Note that adding the decimal point to the <code>100</code> ensures it is treated as a <code>double</code>.</p>