diff --git a/Darlehenberechner.java b/Darlehenberechner.java index 5c29994..7e80057 100644 --- a/Darlehenberechner.java +++ b/Darlehenberechner.java @@ -165,8 +165,11 @@ class Darlehenberechner { } System.out.print("Monat erste Rate(z.B. 2007-12): "); konfig.setAnfangsmonat(YearMonth.parse(dis.readLine())); - System.out.print("Sondertilgungssatz: "); - konfig.setSondertilgungProzent((BigDecimal) DECIMAL_FORMAT.parse(dis.readLine())); + System.out.print("Sondertilgungssatz(optional): "); + in = dis.readLine(); + if (in != null && !in.isBlank()) { + konfig.setSondertilgungProzent((BigDecimal) DECIMAL_FORMAT.parse(in)); + } new Darlehenberechner(konfig).berechneWerte(); /*var konfig = new Konfiguration(); @@ -261,7 +264,7 @@ class Darlehenberechner { private void zahleSondertilgung() { - if (sondertilgung.signum() == 0) { + if (sondertilgung == null || sondertilgung.signum() == 0) { return; } boolean sondertilgungFaellingErstesJahr = summeMonate < 12 && aktMonat.getMonth() == Month.DECEMBER;