[Solved] compound interest calculator on the deposit [closed]


You divided an integer by an integer ((1 + interestRate / 12 / 100)): this produces an integer.

To get the result you expect, either cast interestRate to an int, or parse it as a double like you did with initialAmount:

static double Calculate(string userInput)
{
    var arrString = userInput.Split(' ');
    double initialAmount = double.Parse(arrString[0]);
    int interestRate = double.Parse(arrString[1]);
    // either do this  ^^^^^^

    int countMonth = int.Parse(arrString[2]);

    return initialAmount * Math.Pow((1 + (double)interestRate / 12 / 100), countMonth);
    // or do this                        ^^^^^^^^
}

solved compound interest calculator on the deposit [closed]