Cycle went to minus to fix it.
-
package lessonThree; public class HomeWorkThree { public static void main(String[] args) { int c = 0; for (int a = 1; a < 8; a++) { if (a <= 1) { System.out.println(" Понедельник "); } else if (a <= 2) { System.out.println(" Вторник "); } else if (a <= 3) { System.out.println(" Среда "); } else if (a <= 4) { System.out.println(" Четверг "); } else if (a <= 5) { System.out.println(" Пятница "); } else if (a <= 6) { System.out.println(" Суббота "); } else if (a <= 7) { System.out.println(" Воскресенье "); } for (int b = 1; b < 5; b++) { if (b <= 1) { System.out.println(" Ночь "); } else if (b <= 2) { System.out.println(" Утро "); } else if (b <= 3) { System.out.println(" День "); } else if (b <= 4) { System.out.println(" Вечер "); } do { c += 1; } while (c > 24); if (c >= 24) break; for (int d = 0; d < 60; d++) { if (d > 60) break; System.out.println(" День недели " + a + " Время суток " + b + " Часы " + c + " Минута " + d); } } } } }
The Circle started to leave in less hours, please tell me how to fix it.
-
The mistake is that it's too much investment and it's very difficult to figure out what's there and how, and even in the debager, it's hard to catch, so try to avoid such a coding style. ♪ ♪
You have a variable at a certain.
с
cycling and refilling,int
A flat size between - 2,147,483,648 and 2.147,48647, and when the variable fits to the positive boundary, it crosses negative.byte b = 127; System.out.println(++b);
Conclusion
-128
You have a problem in this block.
do { c += 1; } while (c > 24); if (c >= 24) { break; }
Increments and condition of withdrawal in different blocks, one can try to reschedule the verification to the do block (but this changecorrectly concludes, the problem of large stock)
do { c += 1; if (c >= 24) break; } while (c > 24);
If you ever remove the block, it's kind of working normally.
while (c++ > 24); if (c >= 24) break;
Ideally, this code needs to be rewritten, try to replace the blocks if you switch.