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: