Adds,Multiplies and divides integers using Shell Script

Adds,Subtracts Multiplies and divides two integers

 

Problem Statement : Write a shell script(small calculator) that adds, subtracts, multiplies and divides the given two integers. There are two division options one returns the quotient and the other  returns reminder. The script requires  3 arguments: The operation to be used and two integer numbers.  The options are add(-a), subtract(-s), multiply(-m), quotient(-c) and reminder(-r).

Menu for this Program :

Enter –a for adding
Enter –b for subtraction
Enter –m for multiplication
Enter –c for Quotient
Enter –r for reminder

User can perform any operation by selecting particular option from the Menu.

 Adds,Multiplies and divides integers using Shell Script Code

[button style=”large blue  embossed” link=”https://sites.google.com/site/codesgeeks/codesgeek_1/Adds%2CMultiplies%20and%20divides%20integers%20using%20Shell%20Script%20.sh” target=”_blank” ]Shell Script Code Download[/button]

Adds,Multiplies and divides integers using Shell Script Output

Sample Output 1
mint@mint ~ $ ./script.sh
Enter First Value
20
Enter Second Value
10
Enter –a for adding
Enter –b for subtraction
Enter –m for multiplication
Enter –c for Quotient
Enter –r for reminder
-a
Sum = 30
Enter –a for adding
Enter –b for subtraction
Enter –m for multiplication
Enter –c for Quotient
Enter –r for reminder
-b
difference  = 10
Enter –a for adding
Enter –b for subtraction
Enter –m for multiplication
Enter –c for Quotient
Enter –r for reminder
-m
Product = 200
Enter –a for adding
Enter –b for subtraction
Enter –m for multiplication
Enter –c for Quotient
Enter –r for reminder
-c
quotient = 2
Enter –a for adding
Enter –b for subtraction
Enter –m for multiplication
Enter –c for Quotient
Enter –r for reminder
-r
reminder = 0
Enter –a for adding
Enter –b for subtraction
Enter –m for multiplication
Enter –c for Quotient
Enter –r for reminder

Sample Output 2

mint@mint ~ $ ./script.sh
Enter First Value
30
Enter Second Value
10
Enter –a for adding
Enter –b for subtraction
Enter –m for multiplication
Enter –c for Quotient
Enter –r for reminder
-a
Sum = 40
Enter –a for adding
Enter –b for subtraction
Enter –m for multiplication
Enter –c for Quotient
Enter –r for reminder
-b
difference  = 20
Enter –a for adding
Enter –b for subtraction
Enter –m for multiplication
Enter –c for Quotient
Enter –r for reminder
-m
Product = 300
Enter –a for adding
Enter –b for subtraction
Enter –m for multiplication
Enter –c for Quotient
Enter –r for reminder
-c
quotient = 3
Enter –a for adding
Enter –b for subtraction
Enter –m for multiplication
Enter –c for Quotient
Enter –r for reminder
-r
reminder = 0
Enter –a for adding
Enter –b for subtraction
Enter –m for multiplication
Enter –c for Quotient
Enter –r for reminder