Created
August 12, 2017 07:26
-
-
Save wjfz/08591540e2fef976a4cf2b10ac1656fb to your computer and use it in GitHub Desktop.
rate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Created by PhpStorm. | |
* User: wangjunfengze | |
* Date: 2017/8/12 | |
* Time: 下午2:54 | |
*/ | |
$money = 6988; | |
$rate = 0.07; | |
$subAmount = 605; | |
$totalInterest = 0; | |
for ($i = 1; $i <= 12; $i++) { | |
echo "第 $i 期"; | |
var_dump($money); | |
$interest = round(($money * $rate / 12), 2); | |
var_dump($interest); | |
$totalInterest += $interest; | |
var_dump($totalInterest); | |
echo "\n"; | |
$money = $money - $subAmount; | |
} | |
//$money = 6988; | |
//$money = 7260; | |
// | |
//$subAmount = 605; | |
// | |
//$totalInterest = 0; | |
// | |
//for ($i = 1; $i <= 12; $i++) { | |
// $ii = $i; | |
// if ($i == 12) { | |
// $ii = 11; | |
// } | |
// $rate = 0.06 + 0.005 * ($ii - 1); | |
// echo "第 $i 期,利率 $rate\n"; | |
// echo "剩余本金 $money"; | |
// $interest = round(($money * $rate / 12), 2); | |
// echo "\n本月利息 $interest"; | |
// $totalInterest += $interest; | |
// echo " 总利息 $totalInterest"; | |
// echo "\n\n"; | |
// | |
// $money = $money - $subAmount; | |
//} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment