22.10 Final Push
This commit is contained in:
parent
55bccf151e
commit
0c6a7324fe
@ -1,8 +1,16 @@
|
|||||||
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(){
|
||||||
@ -11,21 +19,21 @@ public class Zahlenfilter {
|
|||||||
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;
|
||||||
|
|
||||||
@ -34,7 +42,4 @@ public class Zahlenfilter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user