gamerzfuse Posted May 8, 2009 Share Posted May 8, 2009 I know there are many calculators out there that calculate monthly payments, etc.. but I just need a simple one that calculates (in a table) the Monthly payments for a vehicle over certain months at different money down at a set interest amount. Example: If I knew where to start that would be super helpful. I am more than willing to build it myself, but I don't even understand the payments myself (not the best Accountant here) Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/157386-solved-monthly-payments-calculator/ Share on other sites More sharing options...
Ken2k7 Posted May 8, 2009 Share Posted May 8, 2009 Well, start with the formula to calculate those numbers. Have you gotten that far? Quote Link to comment https://forums.phpfreaks.com/topic/157386-solved-monthly-payments-calculator/#findComment-829752 Share on other sites More sharing options...
gamerzfuse Posted May 8, 2009 Author Share Posted May 8, 2009 I'm still trying to figure that out. I'm going to go into the dealership and just see if I can get someone else to do the formulas for me. My headache is too much already. Then I guess I can just manually calculate each one? Quote Link to comment https://forums.phpfreaks.com/topic/157386-solved-monthly-payments-calculator/#findComment-829759 Share on other sites More sharing options...
gamerzfuse Posted May 8, 2009 Author Share Posted May 8, 2009 I got it authorized by them to skip that and just program a calculator. Is it easiest to code a calculator in PHP or in Javascript or what? I just need a simple one with Months, Interest Rate, Downpayment, etc. Quote Link to comment https://forums.phpfreaks.com/topic/157386-solved-monthly-payments-calculator/#findComment-829841 Share on other sites More sharing options...
xtopolis Posted May 9, 2009 Share Posted May 9, 2009 Depends on how accurate the calculations need to be. Javascript would be convenient and relatively easy, should the calculations be ok if they are pretty close. PHP with the BC math extension would give more exacting results, and you could use Ajax to make it more user friendly (read: no page refreshing). You only need to figure out the formula, PHP can do the rest. Javascript can handle a lot as well. Quote Link to comment https://forums.phpfreaks.com/topic/157386-solved-monthly-payments-calculator/#findComment-829986 Share on other sites More sharing options...
gamerzfuse Posted May 9, 2009 Author Share Posted May 9, 2009 I would love to use PHP as I am quickly becoming much better at it and the possibilities of PHP are endless from what I have seen. I'm looking into these math functions and they should work. I'll probably have a couple <input> fields that need to be multiplied, shouldn't require anything but multiplication.. although the actual Amortization formula is much more complex and requires ^ (to the power of) values also. I imagine I will easily find the answer while googling in the morning, but I assume there is a way to set input forms to $variables without much hassle? Thanks for all your help, this is the best learning experience I've had in coding since I read HTML For Dummies front to back Quote Link to comment https://forums.phpfreaks.com/topic/157386-solved-monthly-payments-calculator/#findComment-830081 Share on other sites More sharing options...
xtopolis Posted May 9, 2009 Share Posted May 9, 2009 It is really easy.. If you use ajax, technically you don't have to really worry about the form because you'll never actually submit it... (you take the values and append them to the url string). Quote Link to comment https://forums.phpfreaks.com/topic/157386-solved-monthly-payments-calculator/#findComment-830086 Share on other sites More sharing options...
Ken2k7 Posted May 9, 2009 Share Posted May 9, 2009 man pow ^ that function will become useful if you don't know it already. I love the name of that function. POW!!! Say it with pride! Quote Link to comment https://forums.phpfreaks.com/topic/157386-solved-monthly-payments-calculator/#findComment-830102 Share on other sites More sharing options...
gamerzfuse Posted May 9, 2009 Author Share Posted May 9, 2009 Got it. Thanks! Looking into all this soon. Never used Ajax before, but if you can enlighten me I would be very excited to learn! Quote Link to comment https://forums.phpfreaks.com/topic/157386-solved-monthly-payments-calculator/#findComment-830133 Share on other sites More sharing options...
Ken2k7 Posted May 9, 2009 Share Posted May 9, 2009 Depends on what would enlighten you? Quote Link to comment https://forums.phpfreaks.com/topic/157386-solved-monthly-payments-calculator/#findComment-830141 Share on other sites More sharing options...
gamerzfuse Posted May 9, 2009 Author Share Posted May 9, 2009 Well.. I'm going to start Googling Ajax calculator and such. If I can find a generator that saves me time, I will generate a calculator and then clone it so I know how it all works. Quote Link to comment https://forums.phpfreaks.com/topic/157386-solved-monthly-payments-calculator/#findComment-830255 Share on other sites More sharing options...
ionik Posted May 13, 2009 Share Posted May 13, 2009 Here is a payment calculator I wrote for car payments ...... you need to input the amounts in PHP but it works great <?php /* * Fixed Rate Interest Loan Calulator */ // Do you pay on the amount at time of loan purchase? // Or do you pay on the amount of the that you currently owe? // Options // --------------------- // amountOwed | timeofPur $loanType = 'amountOwed'; //Interest Rate // 1-.00 $rate = '.23'; $rateYr = $rate / 365.5; // Amount Of Loan $amount = 10750; // Pay Cycle In Days $payLength = 14; $paymentAmounts = 176; $currentDay = 0; $totalDays = 0; $totalInterest = 0; $totalInterestPayments = array(); $totalAmountPaid = 0; $totalAmountOwed = $amount; $lastPayment = 0; $totalPayments = 0; echo '<span style="font-size: 10px;">'; // Start calulating the total length while ($totalAmountOwed > 0) { // Are we adding interest? if ($currentDay == 365) { // Add in loan interest $interestAdd = ($loanType == 'amountOwed') ? $rate * $totalAmountOwed : $rate * $amount; $totalAmountOwed += $interestAdd; $totalInterest += $interestAdd; $currentDay = 0; echo ' ------------------------------- <br /><br /> INTEREST ADDING <br /><br />'; echo '<strong>Added Interest : </strong> $'.round($interestAdd, 2).' Loan Balance is now $'.round( $totalAmountOwed, 2).' <br /><br />'; echo '<br /><br /> ------------------------------- <br /><br />'; } else { $currentDay++; } if ($lastPayment == $payLength) { if ($totalAmountOwed < $paymentAmounts) { $finalPaymentAmount = $totalAmountOwed; $paymentAmounts = $totalAmountOwed; } // Get the total amount we are paying in interest add to array $interestPaid = $payLength * $rateYr * $totalAmountOwed; $totalPayments++; $totalInterestPayments[] = $interestPaid; $totalAmountPaid += $paymentAmounts; $totalAmountOwed = $totalAmountOwed - $paymentAmounts; $lastPayment = 0; if ($finalPaymentAmount) { echo '<strong>Making final payment of $'.round($paymentAmounts, 2).' and $'.round($interestPaid, 2).' of it is interest <br /><br /> ------------------------------- <br /><br /> LOAN IS PAID IN FULL <br /><br /> ------------------------------- <br /><br />'; } else { echo '<strong>Making a payment of $'.round($paymentAmounts, 2).' and $'.round($interestPaid, 2).' of it is interest loan balance is now $'.round($totalAmountOwed, 2).' <br /><br />'; } } else { $lastPayment++; } $totalDays++; } $interestAddedCount = count($totalInterestPayments); foreach ($totalInterestPayments as $k => $v) { $a++; $interestTotal += $v; } $interestToward = $interestTotal / $interestAddedCount; $yearDay = 0; $year = 0; $monthCount = 0; while( $totalDays != 0) { if ($yearDay == 365) { $year++; $yearDay = 0; } else { $yearDay++; } if ($totalDays < 365) { if ($dayMonth != 30) { $dayMonth++; } else { $monthCount++; $dayMonth = 0; } } $totalDays--; } $interestPercentage = round(($interestToward / $paymentAmounts) * 100); // Breakdown some stats! echo 'Total Payments : '.$totalPayments.' <br />'; echo 'Final Payment Amount : $'.round($finalPaymentAmount,2).' <br />'; echo 'Loan Length : '.$year.' Year(s) '.$monthCount.' Month(s) '.$dayMonth.' Day(s) <br />'; echo 'Interest Paid : $'.round($totalInterest, 2).' <br />'; echo 'Total Cost of Loan : $'.round($totalInterest + $amount, 2).' <br />'; echo 'On Average You will be paying : $'.round($interestToward, 2).' towards interest each payment or '.$interestPercentage.'% of each payment is interest'; ?> </span> Quote Link to comment https://forums.phpfreaks.com/topic/157386-solved-monthly-payments-calculator/#findComment-833254 Share on other sites More sharing options...
gamerzfuse Posted May 14, 2009 Author Share Posted May 14, 2009 Here is a payment calculator I wrote for car payments ...... you need to input the amounts in PHP but it works great Wow.. thanks mate! That's alot more than I expected in an answer. Quote Link to comment https://forums.phpfreaks.com/topic/157386-solved-monthly-payments-calculator/#findComment-833769 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.