Skip to content

lavanyaag23/linux-calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 

Repository files navigation

🧮 Simple Calculator (Linux Shell Script)

An interactive command-line calculator built using Bash Shell Scripting. This project performs basic arithmetic operations directly from the Linux terminal and demonstrates fundamental shell scripting concepts.

Developed as part of a Linux Lab Project.


✨ Features

  • ➕ Addition
  • ➖ Subtraction
  • ✖️ Multiplication
  • ➗ Division
  • 🔄 Menu-driven interface
  • 🚪 Exit option with confirmation
  • ⚠️ Handles invalid user input gracefully

🛠️ Technologies Used

  • Bash Shell Scripting
  • Linux Terminal
  • bc (Basic Calculator Utility)

📋 Prerequisites

Before running the script, ensure you have:

  • Linux / Ubuntu Operating System
  • Bash Shell
  • bc package installed

Install bc if required:

sudo apt install bc

🚀 Getting Started

1️⃣ Save the Script

Save the source code as:

simple_calculator.sh

2️⃣ Make the Script Executable

chmod +x simple_calculator.sh

3️⃣ Run the Script

./simple_calculator.sh

📖 Menu Options

Simple Calculator

1. Addition
2. Subtraction
3. Multiplication
4. Division
5. Exit

Enter your choice (1-5):
Option Operation
1 Addition
2 Subtraction
3 Multiplication
4 Division
5 Exit Program

💻 Example Outputs

➕ Addition

Enter your choice (1-5): 1
Enter two numbers: 10 20

10 + 20 = 30

➖ Subtraction

Enter your choice (1-5): 2
Enter two numbers: 50 20

50 - 20 = 30

✖️ Multiplication

Enter your choice (1-5): 3
Enter two numbers: 6 7

6 * 7 = 42

➗ Division

Enter your choice (1-5): 4
Enter two numbers: 10 3

10 / 3 = 3.33

🚪 Exit

Enter your choice (1-5): 5

Are you sure you want to exit? (y/n): y

Goodbye!

🎯 Learning Outcomes

This project helped in understanding:

  • Shell Scripting Basics
  • Conditional Statements (if-else)
  • Loops (while)
  • User Input Handling
  • Functions in Bash
  • Command-Line Utilities
  • Menu-Driven Programming

Latest Update

  • Updated project documentation.

📚 Academic Purpose

This project was developed as part of the Linux Laboratory coursework to strengthen command-line programming and scripting skills.


👩‍💻 Author

Lavanya Agrawal

B.Tech Computer Science Engineering UPES, Dehradun

GitHub: https://github.com/lavanyaag23

About

Command-line Linux calculator developed using Shell scripting. Supports basic arithmetic operations and demonstrates Linux scripting fundamentals.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages