added using args from main

This commit is contained in:
Tim Lachmann 2024-10-15 15:30:52 +02:00
parent d9b999f31d
commit 02e7b2cb65

View File

@ -3,13 +3,26 @@ package Praktikum01;
public class Zahlenfilter {
public static void main(String[] args) {
int grenze = 200;
if (args.length > 0) {
try {
grenze = Integer.parseInt(args[0]);
} catch (NumberFormatException e) {
System.out.println("Ungültige Eingabe: '" + args[0] + "' ist keine gültige Zahl. Es wird der Standardwert 200 verwendet.");
}
}
Zahlenfilter checker = new Zahlenfilter();
checker.checkZahlen();
checker.checkZahlen(grenze);
}
public void checkZahlen() {
for (int i = 1; i <= 200; i++) {
public void checkZahlen(int grenze) {
for (int i = 1; i <= grenze; i++) {
checkDurchFuenfTeilbar(i);
checkEndetAufNeun(i);
checkSummeMitVorgaenger(i);