Compound interest
Java Loops
loop over years
Flowchart (ISO 5807)
Source code
class Interest {
static double compound(double p, double r, int years) {
double amount = p;
for (int i = 0; i < years; i++) {
amount = amount * (1 + r / 100);
}
return amount;
}
}