From f40374d113ed1d3249e462e4f4c2fd2e6fddd249 Mon Sep 17 00:00:00 2001 From: SteffenLm <33038091+SteffenLm@users.noreply.github.com> Date: Sun, 8 Oct 2023 00:17:34 +0200 Subject: [PATCH 1/2] Implement Solution --- Exercise.java | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/Exercise.java b/Exercise.java index 3c092f9..4294182 100644 --- a/Exercise.java +++ b/Exercise.java @@ -1,6 +1,36 @@ -public class Exercise { +import java.util.Scanner; +public class Exercise { public static void main(String[] args) { - // implement exercise here + Scanner scanner = new Scanner(System.in); + int k; + float p; + int n; + + boolean loop; + do { + System.out.print("Gib bitte das Startkapital ein (in Euro): "); + k = scanner.nextInt(); + + System.out.print("Gib bitte den Prozentsatz ein: "); + p = scanner.nextFloat(); + + System.out.print("Gib bitte die Anzahl Jahre ein: "); + n = scanner.nextInt(); + + System.out.println( + "Ergebnis: Das Endkapital betraegt " + (int) calculateInterest(k, p, n) + " Euro"); + + System.out.print("Willst Du eine weitere Zinsrechnung durchfuehren (true, false)?: "); + loop = scanner.nextBoolean(); + } while (loop); + scanner.close(); + } + + static double calculateInterest(int k, float p, int n) { + if (n == 0) { + return k; + } + return calculateInterest(k, p, n - 1) * (1 + p / 100); } } From 79b3abe51465cd4814ea15f6c34e662b9ef8e621 Mon Sep 17 00:00:00 2001 From: SteffenLm <33038091+SteffenLm@users.noreply.github.com> Date: Fri, 19 Dec 2025 20:58:18 +0000 Subject: [PATCH 2/2] add dev container --- .devcontainer.json | 3 +++ .vscode/extensions.json | 5 +++++ 2 files changed, 8 insertions(+) create mode 100644 .devcontainer.json create mode 100644 .vscode/extensions.json diff --git a/.devcontainer.json b/.devcontainer.json new file mode 100644 index 0000000..bfbeb0d --- /dev/null +++ b/.devcontainer.json @@ -0,0 +1,3 @@ +{ + "image": "mcr.microsoft.com/devcontainers/java:21" +} \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..add4f4e --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "vscjava.vscode-java-pack" + ] +} \ No newline at end of file