File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed
Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change 1+ import java .util .Scanner ;
2+
13public 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}
You can’t perform that action at this time.
0 commit comments