SilentQ-noob- Posted August 22, 2007 Share Posted August 22, 2007 Hi, this will probably sounds pretty simple to some of you, but I'm trying to make a function that calculates user input. The actual function isn't that hard part- it's the math that I'm having trouble with. I want to make a simple mortgage calculator, all it does is it tells you what your monthly payments would be. The fields are List price: Down Payment: Rate: Years(term): what I figured was (list price - down payment) / (Years * 12) ---> (result of years * 12) * rate ??? I'm not very good at math HELPP Quote Link to comment https://forums.phpfreaks.com/topic/66258-math-question/ Share on other sites More sharing options...
lemmin Posted August 22, 2007 Share Posted August 22, 2007 Why would you multiply by 12 agian? I think you have a good start. I'm not sure how interest is calculate, is it by the total price or each individual payment? If it is total price, you can do this: ((list price - down payment)*(rate/100))+(list price - down payment) = total amount owed after interest (total amount owed) / (years * 12) = per month payment. (rate would need to be as a percent) Quote Link to comment https://forums.phpfreaks.com/topic/66258-math-question/#findComment-331404 Share on other sites More sharing options...
btherl Posted August 23, 2007 Share Posted August 23, 2007 Try this out (taken from here) $principal = 400000; $annual_interest = 0.07; $monthly_interest = $annual_interest / 12.0; $years = 30; $months = $years * 12; $monthly_payment = $principal * ( $monthly_interest / (1 - pow(1 + $monthly_interest, -$months))); print "Principal: $principal\n"; print "Annual interest: $annual_interest ($monthly_interest monthly)\n"; print "Years: $years ($months months)\n"; print "Monthly payment: $monthly_payment\n"; Quote Link to comment https://forums.phpfreaks.com/topic/66258-math-question/#findComment-331467 Share on other sites More sharing options...
matthewhaworth Posted August 23, 2007 Share Posted August 23, 2007 Can some moderator please move this to the Math-based php forum? It's a shame that it's not populated.. Quote Link to comment https://forums.phpfreaks.com/topic/66258-math-question/#findComment-331472 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.