8000 Complex expressions are not working · Issue #122 · fasseg/exp4j · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Complex expressions are not working #122
Open
@jaydeepbhayani

Description

@jaydeepbhayani

I have an expression like this -> "(0.341 * 8000.0) / (1 - (1 + 0.341) ^ -84)"

Expected result - "109.71908469357446"
Actual result - "1.538906384258725e-36"

calculation should be done like below snippet

fun calculateMonthlyInstallment(loanAmount: Double, monthlyInterestRate: Double, numberOfMonths: Int): Double {
    val monthlyInterestRateDecimal = monthlyInterestRate / 100.0  // Convert percentage to decimal
    val power = Math.pow(1 + monthlyInterestRateDecimal, -numberOfMonths.toDouble())
    return (monthlyInterestRateDecimal * loanAmount) / (1 - power)
}

fun main() {
    val loanAmount = 8000.0
    val monthlyInterestRate = 0.341  // 0.5% interest rate
    val numberOfMonths = 84
    val monthlyInstallment = calculateMonthlyInstallment(loanAmount, monthlyInterestRate, numberOfMonths)
    println("Monthly Installment: $monthlyInstallment")
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0