Hello linux users. I am studying for my Linux+ exam. I am on an exersice on doing a simple math problem w/ a desicion of calculating the sum or average of 3 numbers entered by the user. Everything is fine in the code until it steps through the case structure. I even had the same problems using the if/then/else. Here is my code:
Code:
#!/bin/bash
### The Name of the file is 'domath0' ###
clear
declare -i A
declare -i B
declare -i C
declare -i ANSWER
echo "Enter #1:"
read A
echo "Enter #2:"
read B
echo "Enter #3:"
read C
echo "Choose Process:"
echo "p : the sum"
echo "v : the average:"
echo "What is your decision?: "
read CHOICE
case $CHOICE in
p | P ) ANSWER = A + B + C ##Here is line 19##
;;
v | V ) ANSWER = A + B + C
ANSWER = $ANSWER / 3
;;
esac
echo "The result is: " $ANSWER "." ## Here is line 25##
exit 0
Now here is the execution/output from shell:
Code:
Enter #1:
1
Enter #2:
2
Enter #3:
3
Choose Process:
p : the sum
v : the average:
What is your decision?:
p
/home/cbattle4654/bin/domath0: line 19: ANSWER: command not found
The result is: .
As a result also, output of line 25 is absent.
I would like to understand what is going on. Am I doing something that I am not seeing? Please clarify with me as soon as possible.
~Thanks