|
|
|
|
|
|
|
|
|
|
|
package praktikum01; |
|
|
|
|
|
|
|
|
|
|
|
public class Zahlenfilter { |
|
|
|
|
|
public static void main(String[] args) { |
|
|
|
|
|
Zahlenfilter check = new Zahlenfilter(); |
|
|
|
|
|
check.checkNumbers(); |
|
|
|
|
|
} |
|
|
|
|
|
public void checkNumbers(){ |
|
|
|
|
|
checkForFive(); |
|
|
|
|
|
endsWithNine(); |
|
|
|
|
|
numberAndPredecessorDividableByThree(); |
|
|
|
|
|
} |
|
|
|
|
|
public void checkForFive (){ |
|
|
|
|
|
for (int i = 1; i <= 200; i++) { |
|
|
|
|
|
if (i%5 ==0){ |
|
|
|
|
|
System.out.println(i + "ist durch 5 teilbar" ); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
public void endsWithNine (){ |
|
|
|
|
|
for (int i = 1; i <= 200; i++) { |
|
|
|
|
|
if (i%10 ==9){ |
|
|
|
|
|
System.out.println(i + "endet auf 9"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
public void numberAndPredecessorDividableByThree(){ |
|
|
|
|
|
for (int i = 2; i <= 200; i++) { |
|
|
|
|
|
int predecessor = i - 1; |
|
|
|
|
|
int sum = i + predecessor; |
|
|
|
|
|
|
|
|
|
|
|
if (sum % 3 == 0) { |
|
|
|
|
|
System.out.println(i + " und " + predecessor + " addiert ergeben " + sum + " und " + sum + " ist durch 3 teilbar."); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |