PHP Classes

PHP Compound Interest Calculator: Calculate compound interest for a given duration

Recommend this page to a friend!
  Info   View files Example   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 197 All time: 8,504 This week: 571Up
Version License PHP version Categories
mtocompbound 1.0.0GNU General Publi...5PHP 5, Finances
Description 

Author

This class can calculate compound interest for a given duration.

It takes as input the initial capital, the interest rate, the number of years and the spare interval in months.

The class can calculate the compound interest to be paid over the given number of years.

It can return the values in an array or display it in a HTML table.

Picture of Marco Tonnicchi
Name: Marco Tonnicchi <contact>
Classes: 2 packages by
Country: Germany Germany
Age: 59
All time rank: 3287187 in Germany Germany
Week rank: 411 Up15 in Germany Germany Up

Example

<?php
error_reporting
( E_ERROR);
 
 
?>
<style TYPE="text/css" MEDIA=screen>

 .error {
     color:red;

 }
    table {
    border-collapse: separate;
    border: 3px solid #585858;
}
td, th {
    padding: .5em;
}
th:first-child {
    padding-left: .4em;
}
th:last-child, td:last-child {
    padding-right: .4em;
}

th {
    font-weight: normal;
    text-align: center;
    border: 3px solid #FFF;
    background-color: #808080;
    color:white;
    font-weight: bold;
}

td {
    text-align: left;
     border: 2px solid #000000;
}
  </style>
 <form>
 <pre>
  Currency : <input type="text" name="currency" value="<?php print $_GET['currency'] ? $_GET['currency']:'$'; ?>">
  Initial capital : <input type="text" name="initial_capital" value="<?php print $_GET['initial_capital'] ? $_GET['initial_capital']:0; ?>">
  Saving amount : <input type="text" name="saving_amount" value="<?php print $_GET['saving_amount'];?>">
  Period in years : <input type="text" name="period" value="<?php print $_GET['period'];?>">
  Interest rate % : <input type="text" name="interest_rate" value="<?php print $_GET['interest_rate'];?>">
  Dynamics % : <input type="text" name="dynamics" value="<?php print $_GET['dynamics'] ? $_GET['dynamics']:0; ?>">
  Interval : <select name="interval">

<?php
 
require_once('class_compbound.php');
 
$label = array('12'=>'monthly','4'=>'quarterly','2'=>'half-yearly','1'=>'yearly');

        if(
$_GET['interval'] ) $iw = $_GET['interval'];
      foreach(
$label as $value => $key )
     {
        
$value = trim($value);
        
$sel = $iw == $value ? 'selected':'';
         print
'<option value="'.$value.'" '.$sel.' >'.$key.'</option>'."\n";
        
     }
?>
</select>
  <input type="submit">
 </pre>
 </form>


<?php
 
if( !$_GET['period'] || !$_GET['interest_rate']) die;
 
$Interest = new compboundInterest;
 if(
$_GET['currency'] ) $Interest->currency = $_GET['currency'];
 
 print
$Interest->create( $_GET['initial_capital'], $_GET['saving_amount'],$_GET['period'],$_GET['interest_rate'],$_GET['interval'],$_GET['dynamics']);
 
 
?>


  Files folder image Files  
File Role Description
Plain text file class_compbound.php Class Class File
Accessible without login Plain text file example.php Example Example file

 Version Control Unique User Downloads Download Rankings  
 0%
Total:197
This week:0
All time:8,504
This week:571Up
User Comments (1)
very much helpfull.
7 years ago (ashish)
70%StarStarStarStar