Takes five arguments : principle years interest points fees
For instance,
bash mortgage.sh 100000 5 .075 0 0
Outputs
Principle + fees = 100000 , Years = 5 , Months = 60 , interest .006250000000
Points = 0 , 0
2003.794859563881
#!/bin/sh
if [[ $# -ne 5 ]]
then
echo "enter 5 args : principle years interest points fees"
exit
fi
prin=$1
((mon=$2 * 12 ))
inter=`echo "scale=12;$3/12" | bc`
pts=`echo "scale=12; $prin * $4" | bc`
fee=$5
prin=`echo "scale=12;$prin + $fee" | bc`
echo "Principle + fees = $prin , Years = $2 , Months = $mon , interest $inter"
echo "Points = $4 , $pts"
prin=`echo "scale=12; $prin - $pts" | bc`
echo `echo "scale=12;($prin*$inter)*((1+$inter)^$mon)/(((1+$inter)^$mon)-1)"|bc`
echo "the monthly payment : $new_prin"