Skip to content

Commit 2f98ea1

Browse files
committed
implement solution
1 parent 8e55ee8 commit 2f98ea1

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

Exercise.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,32 @@
1+
import java.util.Scanner;
2+
13
public class Exercise {
24

35
public static void main(String[] args) {
4-
// implement exercise here
6+
7+
@SuppressWarnings("resource")
8+
Scanner scanner = new Scanner(System.in);
9+
10+
int k;
11+
double p;
12+
13+
boolean loop;
14+
do {
15+
System.out.print("Gib bitte das Startkapital ein (in Euro): ");
16+
k = scanner.nextInt();
17+
18+
System.out.print("Gib bitte den Prozentsatz ein: ");
19+
p = scanner.nextDouble();
20+
21+
System.out.println("Ergebnis: Der Jahreszins betraegt " + (int) calculateInterestPerAnnum(k, p) + " Euro");
22+
23+
System.out.print("Willst Du einen weiteren Jahreszins berechnen (true, false)?: ");
24+
loop = scanner.nextBoolean();
25+
} while (loop);
26+
527
}
28+
29+
static double calculateInterestPerAnnum(int k, double p) {
30+
return k * p / 100;
31+
}
632
}

0 commit comments

Comments
 (0)