Validering af Kapitalfremskrivnings Script.
Hey eksperter.Bryggede lige dette sammen, på en lille time.
kan i se nogle fejl / mangler osv ?
koden :
<?php
$debt = 28785.75; // What you owe in total.
$interest = 1.1255; // Interests each year. 12.55%
$year = date("Y", time())+1; // Next upcomming month.
$month = date("n", time())+1; // Next upcomming month.
$payment = 2000; // Payment each month.
$month_names = array(1 => 'January','February','March','April','May','June','July','August','September','October','November','December');
############ Dont touch anything below here. #############
echo "Year ".($year-1)."<br>\n";
echo "Value: ".$debt."<br>\n";
echo "Monthly Payment : ".$payment."<br>\n<br>\n";
for ($i = 1; $debt >= $payment; $i++) {
if($month % 12 == 1) {
$month = 1;
$new_debt = ($debt*$interest)-$debt;
$new_debt = number_format($new_debt, 2, '.', '');
echo "<br>\nYear ".$year."<br>\n";
echo "Old Value : ".$debt."<br>\n";
echo "Interests added: $new_debt<br>\n";
echo "New Value : ".number_format($debt*$interest,2,'.', '')."<br>\n<br>\n";
$debt = number_format(($debt*$interest) - $payment,2,'.', '');
echo "<b>".$month_names[$month].":</b> ".$debt."<br>\n";
$year++;
$month++;
}
else {
$debt = $debt - $payment;
echo "<b>".$month_names[$month].":</b> ".$debt."<br>\n";
$month++;
}
}
echo "<br>\n<u>Running time: ".$i." months.</u><br>\n";
?>
- BlackScorpion.