Created with <3 with dartpad.dev.
Created
January 17, 2024 12:38
-
-
Save DK070202/565f176bc38a7d83c1bf256424c1d60b to your computer and use it in GitHub Desktop.
crimson-echo-1254
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:math'; | |
int calculateMaturityValue(double P, double i, int n) { | |
double compoundInterest = ((pow(1 + i, n) - 1) / i) * (1 + i); | |
double M = P * compoundInterest; | |
return M.round(); | |
} | |
void main() { | |
double principalAmount = 1000; // Amount | |
int numberOfPeriods = 365; | |
double interestRate = 0.08 / numberOfPeriods; // Assuming monthly compounding | |
int numberOfYear = 1; // Number of years. | |
int numberOfInvestments = numberOfYear * numberOfPeriods; | |
final maturityValue = calculateMaturityValue( | |
principalAmount, interestRate, numberOfInvestments); | |
print("Maturity Value (M): Rs $maturityValue"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment