Developed a multi-functional shell script calculator 🎛️ capable of performing 36+ mathematical operations. This project allowed me to explore Bash scripting 🖥️ and leverage various shell commands for user input, calculations, and output through a user-friendly interface.
- Check Even or Odd 🔄
- Add Two Numbers ➕
- Subtraction ➖
- Multiplication ✖️
- Division ➗
- Square a Number ⏹️
- Square Root √
- Logarithm 📊
- Check Prime Number 🔍
- Sine (Sin x in radians) 📐
- Cosine (Cos x in radians) 🌀
- Tangent (Tan x in radians) 📏
- π (Pi) 𝜋
- e^(x) Exponential 🔺
- Factorial 🎯
- AND Operation (&)
- OR Operation (||)
- NOT Operation (!)
- Convert Decimal to Octal 🔢
- Convert Decimal to Hexadecimal #️⃣
- Convert Binary to Octal 📟
- Convert Decimal to Binary
- Convert Octal to Decimal 🔄
- Convert Binary to Decimal
- Convert Binary to Hex
- Convert Hex to Decimal
- Convert Hex to Binary
- Convert Hex to Octal
- Convert Octal to Binary
- Convert Octal to Hex
- °F to °C
- °C to K
- °F to K
- K to °F
This shell script calculator combines simplicity and versatility, offering an efficient way to handle both everyday and advanced mathematical operations.
-
Run the Calculator Script:
- Open your terminal.
- Navigate to the directory where the script is saved:
cd /path/to/your/script - Make sure the script has execute permissions. If not, you can grant it permission by running:
chmod +x calculator.sh
- Run the calculator script with the following command:
./calculator.sh
-
Initial Prompts:
- After running the script, you will be prompted to enter your name:
Enter Your Name: - Upon entering your name, you will receive a welcome message:
Hello, [Your Name]! Welcome to RN Calculator.
- After running the script, you will be prompted to enter your name:
-
Starting the Calculation:
- Next, you will see a prompt:
Are you ready? 1 = yes / 2 = no - Press
1to start using the calculator.
- Next, you will see a prompt:
Once you are ready, the calculator will display a list of operations it can perform. To select an operation, simply input the corresponding number.
-
Basic Arithmetic:
- Addition: Add two numbers.
- Subtraction: Subtract one number from another.
- Multiplication: Multiply two numbers.
- Division: Divide one number by another.
-
Mathematical Functions:
- Square: Find the square of a number.
- Square Root: Calculate the square root of a number.
- Logarithm: Compute the logarithm of a number.
- Prime Check: Determine whether a number is prime.
- Trigonometric Functions: Sine, Cosine, Tangent (in radians).
- π (Pi): Retrieve the value of Pi.
- e^x: Calculate the exponential of a number.
- Factorial: Calculate the factorial of a number.
-
Logical and Boolean Operations:
- AND (&&), OR (||), NOT: Perform logical comparisons.
-
Conversion Functions:
- Convert between Decimal, Binary, Octal, and Hexadecimal.
-
Temperature Conversions:
- Fahrenheit to Celsius (°F to °C)
- Celsius to Kelvin (°C to K)
- Fahrenheit to Kelvin (°F to K)
- Kelvin to Fahrenheit (K to °F)
-
Addition:
- Choose operation
2for addition. - Input two numbers:
Enter 1st Number: 5 Enter 2nd Number: 7 Ans: 12
- Choose operation
-
Temperature Conversion (°F to °C):
- Choose operation
23. - Input the temperature in Fahrenheit:
Enter the Number: 98.6 98.6 °F = 37 °C
- Choose operation
To close the session, enter 0 in the main menu. You will receive a friendly goodbye message: