Results 1 to 3 of 3
I have some project for linux class and we have to make a command line program to do something and I figured I'd make a simple calculator here is what ...
- 05-03-2009 #1Just Joined!
- Join Date
- May 2009
- Posts
- 2
Creating a simple Command line linux calculator
I have some project for linux class and we have to make a command line program to do something and I figured I'd make a simple calculator here is what I have:
I'm skipping most of the stupid code that isn't necessary aka most of the echos and user prompts
but:
The user is prompted to enter two numbers NUM1 and NUM2, after which they have another prompt to select which operator to use.
the output gives me a '0' every time..why is that?Code:echo -n "please enter the first number" read NUM1 echo -n "Please enter the second number." read NUM2s echo -n "Please enter which operator you would like to use" read selection case $selection in m) let ans=num1*num2 ; echo $ans;; *) echo -n "Please enter proper data" esac echo " "
- 05-03-2009 #2Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
That's probably because NUM1 and num1 are two different variable names. Case matters.
- 05-04-2009 #3Just Joined!
- Join Date
- May 2009
- Posts
- 2


Reply With Quote
