You need another loop, something along the lines of
double width = highBound - lowBound;
double epsilon = .001; // This determines how accurate you want the solution to be, closer to zero = more accurate
double prevValue = -1.0;
double curValue = -1.0; // initialize curValue to a negative value with greater magnitude than epsilon - this ensures that the while loop evaluates to true on the first pass
do {
... // this is where your for loop goes
prevValue = curValue;
curValue = sumOfArea;
width /= 2.0;
} while(Math.abs(prevValue - curValue) > epsilon);
The idea is that you keep decreasing the rectancles' width until the sumOfArea with width = w is more-or-less the same (i.e. within epsilon) as the sumOfArea with width = 2w.
There are faster + more accurate integration algorithms out there e.g. Newton-Cotes, but I'm assuming you don't have a choice in the matter.