I've created a program where I can specify the length, width and height of the area I want my turtle to dig, and I was trying to have it calculate how much fuel it needs to perform a job before doing it. However, I'm having trouble with the calculations, I'm really not sure how to do them.

I can easily get the total measurement of the area that it's going to dig, but that isn't enough, since the turtle will go up as many blocks as defined by the specified Height (minus one) and then come back down before moving forward to dig the next set of blocks. This makes it waste a bit extra fuel and it's the part that's confusing me most.

Here's my program if you're interested. The function checkFuel() has the calculations I was attempting but that didn't work…

Any help would be highly appreaciated.