Stand 001/14.10/15:56
This commit is contained in:
@@ -2,10 +2,9 @@ package praktikum01;
|
||||
|
||||
|
||||
public class Zahlenfilter {
|
||||
static int temp = 0;
|
||||
static int wiederholen;
|
||||
|
||||
public static void main(String[] args) {
|
||||
int wiederholen;
|
||||
|
||||
if( args.length == 0){
|
||||
wiederholen= 200;
|
||||
@@ -13,31 +12,30 @@ public class Zahlenfilter {
|
||||
else {
|
||||
wiederholen= Integer.parseInt(args[0]);
|
||||
}
|
||||
printNumbers();
|
||||
System.out.println(wiederholen);
|
||||
System.out.println(args.length);
|
||||
for (int i = 0; i < wiederholen ; i++ ){
|
||||
//System.out.println(args.length);
|
||||
}
|
||||
|
||||
System.out.println("Zahl |" +i+"|");
|
||||
private static void printNumbers(){
|
||||
for (int i=1; i <=wiederholen; i++)
|
||||
|
||||
//DURCH 5 TEILBAR---------------------------------------------------//
|
||||
if(filter(i))
|
||||
System.out.println(i);
|
||||
}
|
||||
|
||||
if (i % 5== 0){
|
||||
System.out.println(" '-----> ["+i+"] ist durch 5 teilbar!");
|
||||
}
|
||||
public static boolean filter(int i){
|
||||
return !(checkDivisibleBy5(i) || checkEndsWith9(i) || checkSumDivisibleBy3(i, i-1));
|
||||
}
|
||||
|
||||
//AM ENDE EINE 9---------------------------------------------------//
|
||||
if (i %10 ==9){
|
||||
System.out.println(" '-----> [" +i+"] ist endet auf 9!");
|
||||
}
|
||||
public static boolean checkDivisibleBy5(int i){
|
||||
return (i % 5== 0);
|
||||
}
|
||||
public static boolean checkEndsWith9(int i){
|
||||
return (i %10 ==9);
|
||||
}
|
||||
|
||||
//ADDIERT DURCH 3 TEILBAR -----------------------------------------//
|
||||
if ((i + temp) % 3 ==0){
|
||||
int ergebnis = i +temp;
|
||||
System.out.println(" '-----> ["+i+"] und [" +temp+ "] addiert ergeben [" +ergebnis + "] und [" +ergebnis+ "] ist durch 3 teilbar");
|
||||
}
|
||||
//ZUWEISUNG TEMP WERT----------------------------------------------//
|
||||
temp = i;
|
||||
|
||||
}
|
||||
public static boolean checkSumDivisibleBy3(int i, int j) {
|
||||
return ((i + j) % 3 ==0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user