Jump to content

Recommended Posts

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

 

 

Link to comment
https://forums.phpfreaks.com/topic/66258-math-question/
Share on other sites

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)

Link to comment
https://forums.phpfreaks.com/topic/66258-math-question/#findComment-331404
Share on other sites

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";

 

Link to comment
https://forums.phpfreaks.com/topic/66258-math-question/#findComment-331467
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.