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:
32:
33:
34:
35:
|
import java.util.List;
import java.util.ArrayList;
import java.util.Scanner;
public class BankingAccount {
public static void main(String[] args){
List<Double> account = new ArrayList<>();
Scanner scanner = new Scanner(System.in);
System.out.println("Bitte geben Sie Ihre Einzahlungen/Abbuchungen ein.");
System.out.println("Sie beenden die Eingabe mit einer Leerzeile");
String input;
while ((input = scanner.nextLine()) != null){
if (input.equals("")){
break;
}
account.add(Double.valueOf(input));
}
double sum = account.stream().mapToDouble(Double::doubleValue).sum();
double zins = 50;
double result = sum * ((zins / 100) + 1);
double diff = result - sum;
if (zins > 0){
System.out.println("Gewinn durch Zinsen: " + diff);
} else {
System.out.println("Verlust durch Zinsen: " + diff);
}
scanner.close();
}
} |