Skip to content

Solution for Loops 07 #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: exercises/loops/07
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion Exercise.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
import java.util.Scanner;

public class Exercise {

public static void main(String[] args) {
// implement exercise here

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);

scanner.close();
}

static double calculateInterestPerAnnum(int k, double p) {
return k * p / 100;
}
}