|
|
|
|
|
|
|
|
package praktikum01; |
|
|
package praktikum01; |
|
|
|
|
|
|
|
|
public class Zahlenfilter { |
|
|
public class Zahlenfilter { |
|
|
|
|
|
int range = 200; |
|
|
public static void main(String[] args) { |
|
|
public static void main(String[] args) { |
|
|
Zahlenfilter check = new Zahlenfilter(); |
|
|
Zahlenfilter check = new Zahlenfilter(); |
|
|
|
|
|
if(args.length >0){ |
|
|
|
|
|
try{ |
|
|
|
|
|
check.range = Integer.parseInt(args[0]); |
|
|
|
|
|
}catch (NumberFormatException e){ |
|
|
|
|
|
System.out.println("Syntax error"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
check.checkNumbers(); |
|
|
check.checkNumbers(); |
|
|
} |
|
|
} |
|
|
public void checkNumbers(){ |
|
|
public void checkNumbers(){ |
|
|
|
|
|
|
|
|
numberAndPredecessorDividableByThree(); |
|
|
numberAndPredecessorDividableByThree(); |
|
|
} |
|
|
} |
|
|
public void checkForFive (){ |
|
|
public void checkForFive (){ |
|
|
for (int i = 1; i <= 200; i++) { |
|
|
|
|
|
|
|
|
for (int i = 1; i <= range; i++) { |
|
|
if (i%5 ==0){ |
|
|
if (i%5 ==0){ |
|
|
System.out.println(i + "ist durch 5 teilbar" ); |
|
|
System.out.println(i + "ist durch 5 teilbar" ); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
public void endsWithNine (){ |
|
|
public void endsWithNine (){ |
|
|
for (int i = 1; i <= 200; i++) { |
|
|
|
|
|
|
|
|
for (int i = 1; i <= range; i++) { |
|
|
if (i%10 ==9){ |
|
|
if (i%10 ==9){ |
|
|
System.out.println(i + "endet auf 9"); |
|
|
System.out.println(i + "endet auf 9"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
public void numberAndPredecessorDividableByThree(){ |
|
|
public void numberAndPredecessorDividableByThree(){ |
|
|
for (int i = 2; i <= 200; i++) { |
|
|
|
|
|
|
|
|
for (int i = 2; i <= range; i++) { |
|
|
int predecessor = i - 1; |
|
|
int predecessor = i - 1; |
|
|
int sum = i + predecessor; |
|
|
int sum = i + predecessor; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |