I wrote this code, and everything was working well, but part of the assignment is that it must include nested loops. Once I added the nested while loop, which is basically an if statement, my life was ruined. I am trying to nest a loop in the code that will basically tell the compiler that if the value "loopVol" were to exceed the value of "final" after adding an increment, to run the program for the "final". How can I do that?
initial = 10
final = 123
increment = 10
as of now, the program would stop at 120, but I want to nest a loop that will tell the compiler to calculate at the final if this happens.
Once you set loopVol = final - you get an infinite loop because the while is checking to see if loopVol <= final, which will then always be true. Did you mean to use a break statement instead of continue to stop the loop at that point?
1 2 3 4 5 6 7 8 9 10
while (loopVol <= final)
if ((loopVol += increment) >= final)
loopVol = final; //single equal sign
continue; // break; ?