Logo 
Search:

Unix / Linux / Ubuntu Articles

Submit Article
Home » Articles » Unix / Linux / Ubuntu » Homework HelpRSS Feeds

Program of calculator

Posted By: Audris Schmidt     Category: Unix / Linux / Ubuntu     Views: 7397

Program of calculator which performs below operations

Addition
Subtract
Division
Multiplication

Code for Program of calculator in Unix / Linux / Ubuntu

count=0
while [ $count -eq 0 ]
do
    tput clear
    echo "1. Addition"
    echo "2. Subt"
    echo "3. Multi"
    echo "4. Divi"
    echo "5. Exit"
    echo -e "Enter Yr choice : \c"
    read choice

    if [ $choice -ne 5 ]
    then
        echo -e "Enter first number : \c"
        read a
        echo -e "Enter second number : \c"
        read b
    fi
    case $choice in
    1)    ans=`echo $a + $b | bc`
        echo "Addition is $ans"
        ;;
    2)    ans=`echo $a - $b | bc`
        echo "Sub is $ans"
        ;;
    3)    ans=`echo $a \* $b | bc`
        echo "Multi is $ans"
        ;;
    4)    echo scale=2 | bc
        ans=`echo $a / $b | bc`
        echo "Divi is $ans"
        ;;
    5)    exit 1
        ;;
    *)    echo "Invalid Choice !!!"
        ;;
    esac
    sleep 3
done
  
Share: 


Didn't find what you were looking for? Find more on Program of calculator Or get search suggestion and latest updates.

Audris Schmidt
Audris Schmidt author of Program of calculator is from Frankfurt, Germany.
 
View All Articles

 

Other Interesting Articles in Unix / Linux / Ubuntu:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!