Okay, I have two variables in my program.... runSize, which is the total number of cycles the program WILL run, and cycleCount, which is the total number it HAS run. I know that it runs 9 cycles per minute (close enough anyway) so I wrote this to estimate the minutes remaining:
int t = ((runSize - CycleCount) / 9);
This gave me an approximate minutes remaining to complete the run. The only thing I didn't like was that, because it only displayed whole minutes, it went to 0 when there were still 8 cycles remaining. Not a big deal for what I'm using it for but I decided to change the code to this:
int t = ((runSize - CycleCount) / 9 + 1);
This worked the same but it added one minute to the estimate so now the display reads 1 minutes remaining during the entire last minute then goes to zero as the run completes. So then I decided to try breaking the minutes down into hours and minutes using the following:
int t = ((runSize - CycleCount) / 9 + 1); int h = (t / 60); int m = (t - (h * 60));
My assumption was that because the first equation had returned a whole number that would stay true so h = (t / 60) would be a whole number, which of course would be the hours. Then I could use that number multiplied by 60 with the result subtracted from t to give the the "leftover" minutes.
But what I'm getting is the result of int t = ((runSize - CycleCount) / 9 + 1); showing up as the hours and the minutes are always zero. I thought I was using sound logic but I think I'm assuming something that isn't correct. Can you tell me where my flaw is?