Level Sensor Height Change conversion to gallons

Presuming your container has vertical sides, this will be a linear relationship so no need for a big complex if statement, instead how about:

float gallonsValue;  // belongs up in your declarations section 
gallonsValue = inches * 0.125; // where you had that huge IF planned to go

Cheers !
Geoff