Current location: Hot Scripts Forums » Programming Languages » PHP » Need help with a loan calculator


Need help with a loan calculator

Reply
  #1 (permalink)  
Old 11-11-06, 01:35 AM
spinnerd spinnerd is offline
Newbie Coder
 
Join Date: Nov 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Question Need help with a loan calculator

I have this loan calculator that calculates according to the number of years, but I need it to calculate in months. now I know it's probebly someting stupid that I missed here, can someone help. script is below

------------------------
PHP Code:

<form method=GET action=<?php echo $_SERVER["PHP_SELF"] ."#mortgage" ?>>

    
    
  <br>
    Amount ( R ): 
    <input  size=15 name="loan_amount" type="text" >
  <br>
  <br>
    Interest Rate : <input  size=15 name="interest"   type="text" >
  <br>
  <br>
    Years to Pay :  
    <input  size=15 name="years"   type="text" >
    <br>    
    
    
  <?

if (isset($_GET['calculate']) && (floatval($loan_amount) != 0) && (floatval($interest) != 0) && (floatval($years) != 0)   )

{

$pow pow((+ ($interest 1200)), ($years 12)); 

$payment = ($loan_amount $pow) * ($interest 1200) / ($pow 1)  ;
echo 
"<br>";
echo 
"Monthly Payment = R";
echo 
round($payment);
echo 
"<br>";

}

?><br><center><input  name="calculate" value=Calculate type="submit">
    <input type="reset" name="Reset" value="Reset">
  </center></form>
--------------------------------------

Last edited by spinnerd; 11-11-06 at 01:49 AM.
Reply With Quote
  #2 (permalink)  
Old 11-11-06, 12:54 PM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
Quote:
Originally Posted by spinnerd
I have this loan calculator that calculates according to the number of years, but I need it to calculate in months. now I know it's probebly someting stupid that I missed here, can someone help. script is below
what do you mean exactly? atm you're calculating everything in months ($year * 12 = $months)? or do you want the user to enter the number of months? if so, simply rename year to month (both the inputfield and the variable), and don't multiply it with 12

UnrealEd
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
  #3 (permalink)  
Old 11-15-06, 03:18 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
in reply to your pm:
Quote:
Originally Posted by spinnerd
Thanx for the help. Yes the user must enter the amount of months. You also said I should not multiply it with 12 , what should I change this value to?

Thanx again for your help.
this is how your code could look like:
PHP Code:

<form method=GET action=<?php echo $_SERVER["PHP_SELF"] ."#mortgage" ?>>

    
    
  <br>
    Amount ( R ): 
    <input  size=15 name="loan_amount" type="text" >
  <br>
  <br>
    Interest Rate : <input  size=15 name="interest"   type="text" >
  <br>
  <br>
    Years to Pay :  
    <input  size=15 name="months"   type="text" >
    <br>    
    
    
  <?

if (isset($_GET['calculate']) && (floatval($loan_amount) != 0) && (floatval($interest) != 0) && (floatval($months) != 0)   )

{

$pow pow((+ ($interest 1200)), $months); 

$payment = ($loan_amount $pow) * ($interest 1200) / ($pow 1)  ;
echo 
"<br>";
echo 
"Monthly Payment = R";
echo 
round($payment);
echo 
"<br>";

}

?><br><center><input  name="calculate" value=Calculate type="submit">
    <input type="reset" name="Reset" value="Reset">
  </center></form>
Greetz,
UnrealEd
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
  #4 (permalink)  
Old 11-15-06, 05:03 AM
spinnerd spinnerd is offline
Newbie Coder
 
Join Date: Nov 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Thank you once again, appreciate the help.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
modify script 32675 PHP Mortgage Calculator avail General HotScripts Site Discussion 1 12-19-05 04:10 PM
Hows Ma' Site folks? umairunique5k Website Reviews 3 08-05-04 08:37 PM


All times are GMT -5. The time now is 05:45 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.