fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8.  
  9. class Test {
  10.  
  11. public static void main(String[] args) {
  12. int a = 2; int b = 3; int count = 1;
  13. System.out.println( "A: " + a + " B: " + b);
  14. for (int i = a; i < 5*a; i = i + 2) {
  15. System.out.println( "Durchgang: " + count);
  16. System.out.println( "A: " + a + " B: " + b);
  17. switch ( i % 3) {
  18. case 0: a = a - 1; b = b / 2;
  19. System.out.println( "Switch-case 0:");
  20. System.out.println( "A: " + a + " B: " + b);
  21. break;
  22. case 1: a = a + 1; b = b +1;
  23. System.out.println( "Switch-case 1:");
  24. System.out.println( "A: " + a + " B: " + b);
  25. break;
  26. }
  27. count++;
  28. }
  29.  
  30. }
  31. }
  32.  
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout
A: 2 B: 3
Durchgang: 1
A: 2 B: 3
Durchgang: 2
A: 2 B: 3
Switch-case 1:
A: 3 B: 4
Durchgang: 3
A: 3 B: 4
Switch-case 0:
A: 2 B: 2
Durchgang: 4
A: 2 B: 2