You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Main.java 876B

12345678910111213141516171819202122232425262728
  1. package prak1;
  2. public class Main {
  3. public static void main(String[] args) {
  4. int loopLength = 200;
  5. if (args != null && args.length != 0) {
  6. loopLength = Integer.parseInt(args[0]);
  7. }
  8. int previousValue = 0;
  9. for (int i = 0; i <= loopLength; i++) {
  10. if (i == 0) {
  11. continue;
  12. } else if (i % 5 == 0) {
  13. System.out.println(i + " ist durch 5 teilbar!");
  14. } else if (Integer.toString(i).endsWith("9")) {
  15. System.out.println(i + " endet auf 9!");
  16. } else if ((i + previousValue) % 3 == 0) {
  17. int res = i + previousValue;
  18. System.out.println(i + " und " + previousValue + " addiert ergeben " + res + " und " + res + " ist durch 3 teilbar.");
  19. }
  20. previousValue = i;
  21. }
  22. }
  23. }