Capacity of fuelling a car
<p>Having problems trying to reach a capacity on my program. I can't let the program go beyond the weight of the car divided by 100. for example if I type 3,000 in kgs, I will have 30 gallons, but if I refuel the tank and add 31, it will say 31, but I only want 30 instead of 31.  How do you stop this addition. </p>

<p>Here's my code.</p>

<pre><code> public double fuel(double gallons)
 {
   if (gallons &lt;= 0)
   {
     return 0.0;
   }
   if (gallons &lt;= kgs/100.0)
   {
     fuel = kgs/100.0;
     return kgs/100.0;
   }
   else
   {
     fuel = fuel + gallons;
     return gallons;
   }
 }
</code></pre>
