-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathExercise.java
More file actions
31 lines (23 loc) · 789 Bytes
/
Exercise.java
File metadata and controls
31 lines (23 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import java.util.Scanner;
public class Exercise {
public static void main(String[] args) {
@SuppressWarnings("resource")
Scanner scanner = new Scanner(System.in);
int k;
double p;
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.nextDouble();
System.out.println(
"Ergebnis: Der Jahreszins betraegt " + (int) calculateInterestPerAnnum(k, p) + " Euro");
System.out.print("Willst Du einen weiteren Jahreszins berechnen (true, false)?: ");
loop = scanner.nextBoolean();
} while (loop);
}
static double calculateInterestPerAnnum(int k, double p) {
return k * p / 100;
}
}