The program is supposed to pull in data from an input file and sum numbers and not exceed 1000 and then stop, but it seems that my code is making it not calculate properly, it is less than it is supposed to be, but doesn't add to what is present. The numbers in red are the ones that should be summed, it is getting some weird number from somewhere.
INPUT:
55 67 458 23 81 33
782 375 528
405 324 950 46
14 864 551 38 167 518 630
OUTPUT:
702(But should be 717)
//Part H
FileIn.open ("M:\\DataFile2.txt");
int sum4 = 0;
int NUM4;
bool done = true;
while (done)
{
FileIn >> NUM4;
sum4 = sum4 + NUM4;
if ( sum4 + NUM4 > 1000 )
done = false;
else if ( sum4 + NUM4 < 1000 )
sum4 = sum4 + NUM4;
}
FileOut << sum4 << " ";