i am working on making a simple program for the refuelling of an aircraft but i am stuck in a very crucial part of it.

i have 6 airprts

A-B

B-C

C-D

D-E

E-F

Each airport travel has a particular distance it has to cover. the destination of the aircraft is actually A-F but it passes through all these airports in case it needs to refuel. lets say at airport D we have the fuel left in the tank is 25 gallons and the capacity of the tank is 30gallons. we we dont know if the fuel left in the tank can take the aircraft through another from D-E so i have to calculate the total fuel left in the tank and compare it to the fuel capacity. if it is more than the capacity we need to refuel at stop D. i am having a problem with than calculating the total and then compaing it to the tank capacity. please help