praktikum 1.2
This commit is contained in:
parent
7990020fd2
commit
43ed9d5a70
@ -1,8 +1,8 @@
|
||||
package Praktikum3;
|
||||
|
||||
public class ZahlenFilter {
|
||||
public void durchlaufenUndPruefen() {
|
||||
for (int zahl = 1; zahl <= 200; zahl++) {
|
||||
public void durchlaufenUndPruefen(int maxZahl) {
|
||||
for (int zahl = 1; zahl <= maxZahl; zahl++) {
|
||||
pruefeDurch5Teilbar(zahl);
|
||||
pruefeEndetAuf9(zahl);
|
||||
pruefeDurch3TeilbarMitVorgaenger(zahl);
|
||||
@ -34,7 +34,16 @@ public class ZahlenFilter {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
int maxZahl = 200; // Standardwert
|
||||
if (args.length > 0) {
|
||||
try {
|
||||
maxZahl = Integer.parseInt(args[0]);
|
||||
} catch (NumberFormatException e) {
|
||||
System.out.println("Ungültiger Parameter. Verwende Standardwert 200.");
|
||||
}
|
||||
}
|
||||
|
||||
ZahlenFilter pruefung = new ZahlenFilter();
|
||||
pruefung.durchlaufenUndPruefen();
|
||||
pruefung.durchlaufenUndPruefen(maxZahl);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user