Skip to content

Instantly share code, notes, and snippets.

@whizyrel
Created November 13, 2023 22:15
Show Gist options
  • Select an option

  • Save whizyrel/e4b342941fbbed245942514c0035f979 to your computer and use it in GitHub Desktop.

Select an option

Save whizyrel/e4b342941fbbed245942514c0035f979 to your computer and use it in GitHub Desktop.
package org.evryword.simpleinterest;
public class SimpleInterest {
public static void main(String[] args) {
final double totalInterest = calculateSimpleInterest();
System.out.format("[totalInterest] %f", totalInterest);
}
public static double calculateSimpleInterest() {
final int n = 10;
double a = 0;
final int p = 1000;
final double r = 5 / 100;
for (int i = 0; i < n; i++) {
a = a + (p * (1 + r) * (i + 1));
}
return a;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment