-3
#!/bin/sh

echo "welcome to salary calculator"
echo "Enter basic salary"
read basic
dp=$(( basic / 2 ))
da=$((( basic + dp ) * 35) / 100)
hra=$((( basic + dp ) * 8 )/ 100)
ma=$((( basic + dp ) * 8 ) / 100)
pf=$((( basic + dp ) * 10 ) / 100)
salary=$((((( basic + dp) + da ) + hra ) + ma - pf ))
echo "salary is=$salary"
dr_
  • 28,763
  • 21
  • 89
  • 133
sardar
  • 1
  • 1
  • 2
    Hi sardar, welcome to Unix&Linux stack exchange. Please reformat your script to be readable (e.g. indent by 4 spaces) and expand the content to make it clear what your question is. – steve Aug 18 '15 at 12:33
  • 2
    possible duplicate of [basic division using variable and integer](http://unix.stackexchange.com/questions/103444/basic-division-using-variable-and-integer) – FelixJN Aug 18 '15 at 12:42
  • `da=$((( basic + dp ) * 35 / 100))` and so on – Costas Aug 18 '15 at 12:43

1 Answers1

3

You will need to enclose the shell math with $(( ... ))

So the math will need to be:

dp=$((    basic / 2                ))
da=$((  ((basic + dp) * 35 ) / 100 ))
hra=$(( ((basic + dp) *  8 ) / 100 ))
ma=$((  ((basic + dp) *  8 ) / 100 ))
pf=$((  ((basic + dp) * 10 ) / 100 ))
salary=$(( ((((basic + dp ) + da ) + hra) + ma - pf) ))

You may place additional spaces within $(( .. )) to format the lines for readability.

Lambert
  • 12,495
  • 2
  • 26
  • 35