Start New Discussion within our Software Development Community

Writing a small program that requires me to convert strings to doubles and then back to strings. Right now, the code compiles but the answer is wrong, even though I am using an algorithm that I know is right in C++. Can someone tell me what I'm doing wrong? The answer that comes out always very large and random.

        //Converting Strings to Double INT's
        double myMonths = [monthsString doubleValue];
        double myBalance = [balanceString doubleValue];
        double myInterest = [interestString doubleValue];
        //Payment Algorithm
        myInterest = (myInterest/100)/12;
        double AlmostDone = (myInterest * pow(1 + myInterest, myMonths)) * (myBalance/(pow(1 + myInterest, myMonths) -1));
        //Converting a double INT back to a String
        NSString *FinalPayment = [NSString stringWithFormat:@"%d", AlmostDone];
        //Print to Screen
        NSString *paymentScreen = [[NSString alloc] initWithFormat:@"In order to pay your debt in %@ months, you need to pay an average of %@ per month.", monthsString, FinalPayment];
        self.label.text = paymentScreen;
This question has already been answered. Start a new discussion instead.