Jump to content

Math Question


SilentQ-noob-

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.