Skip to content

Instantly share code, notes, and snippets.

Created January 1, 2013 00:55
Show Gist options
  • Save anonymous/4424309 to your computer and use it in GitHub Desktop.
Save anonymous/4424309 to your computer and use it in GitHub Desktop.
#!/bin/bash
bottle=12.5
s=6.95
i=1
tabspace=" "
defmax=5
if [ -z $1 ]; then
max=$defmax
else
max=$1
fi
while [[ $i -lt $max ]]; do
total=`echo "($i * $bottle) + $s" | bc -l`
if [[ $i -ge 5 ]]; then
total=`echo "$total * .95"|bc -l`
fi
echo "Bottles: $i"
echo "${tabspace}Total: $total"
echo -n "${tabspace}Cost per oz: "
echo "$total / (3 * $i)" | bc -l
half=`echo $total / 2 | bc -l`
echo "${tabspace}50%: $half"
i=$(($i+1))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment