0

Why result always same?, output always "good". input value integer

printf "Masukkan nilai IPK : "
read ipk

if [[ $ipk -ge 3,50 && $ipk -le 4,00 ]]; 
  then printf "Awesome"
elif [[ $ipk -ge 2,75 && $ipk -lt 3,50 ]]; 
  then printf "Nice"
elif [[ $ipk -ge 2,00 && $ipk -lt 2,75 ]]; 
  then printf "Good"
else
    echo "Sorry"
fi

Example output code like

Input : Masukkan nilai IPK : 3
Output : Good 
Input : Masukkan nilai IPK : 4
Output : Good 
xNapz
  • 7
  • 1
  • 1
    You are doing integer comparision (`-gt`, `-lt`), but your argument has a comma in it (and therefore isn't an integer). You can see that `echo $((2,75))` produces `75` and `echo $((2,00))` outputs 0, and since the integer comparision operators impose numeric context on their arguments, your comparision is equivalent to `[[ $ipk -ge 0 && $ipk -lt 75 ]]`. – user1934428 Nov 18 '22 at 07:45

0 Answers0