Klar med övning 2, labb 4

This commit is contained in:
Jack-Benny Persson 2013-12-12 15:09:50 +01:00
parent bfbd649d5d
commit 2b023b598c

32
Labb4/ovning2.sh Executable file
View File

@ -0,0 +1,32 @@
#!/bin/bash
# Jack-Benny Persson
# LX13
# Övning 2, labb 4
# Define some variables
Rate="6.3"
# Run it
printf "Do you want to convert from SEK or USD? "
read Exchange
if [ "$Exchange" != "USD" ] && [ $Exchange != "SEK" ]; then
echo "Enter USD or SEK"
exit 2
fi
printf "Enter amount: "
read Amount
case "$Exchange" in
USD)
Answer=`echo "scale=2;$Amount*$Rate" | bc`
printf "$Amount USD is $Answer SEK\n"
;;
SEK)
Answer=`echo "scale=2;$Amount/$Rate" | bc`
printf "$Amount SEK is $Answer USD\n"
;;
esac