Issue
echo "Enter the principal value -> "
read P
echo "Enter the rate of intrest -> "
read R
echo "Enter the number of years -> "
read t
echo "Enter the number of times applied per year ->"
read n
echo "The principal ,rate of interest and number of years are $P $R $t"
s=`echo $P \* $R \* $t \* 0.01 | bc -l`
echo "The simple Interest is $s"
amt=`echo "scale=2;$P * ( 1 + $R * $t )" | bc -l`
echo "The amount is $amt"
power=`expr $n \* $t`
echo $power
ci=`echo "scale=2;$P * ( 1 + $r / $n ) ^ $power" | bc`
echo "The compound intrest is $ci"
(standard_in) 1: syntax error I am getting this error while executing the code. Can anyone help me with this?
Solution
In ci='echo "scale=2;$P * ( 1 + $r / $n ) ^ $power" | bc'
you are trying to access $r
but you only define $R
.
This should fix it
ci='echo "scale=2;$P * ( 1 + $R / $n ) ^ $power" | bc'
Or assign a value to r
Answered By - bench