Test: normal

This commit is contained in:
Orlando
2023-11-23 15:56:41 +01:00
parent 87e8a53f9e
commit 00fbab3375
4 changed files with 93 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
package Prak1;
public class zahlenfilterNeu {
public static void main(String[] args) {
printNumbers();
}
private static void printNumbers(){
int grenze = 20;
int i;
for (i=1; i<=grenze; i++){
if(filter(i)){
System.out.println(i);
}
}
}
public static boolean filter(int i){
return !(durch5teilbar(i) || endetMit9(i) || summeDurch3(i));
}
public static boolean durch5teilbar(int i) {
if (i % 5 == 0) {
return true;
} else {
return false;
}
}
public static boolean endetMit9(int i) {
if (i % 10 == 9) {
return true;
} else {
return false;
}
}
public static boolean summeDurch3(int i) {
int x = i + (i - 1);
if (x % 3 == 0) {
return true;
} else {
return false;
}
}
}