A simple command-line calculator built in Swift.
This is my first Swift project — a small but fun way to learn the language.
- Basic arithmetic: addition, subtraction, multiplication, and division
- Input validation (handles invalid numbers and division by zero)
- Clean CLI interface
- Easily extendable for new operations
-
Clone the repository:
git clone https://github.com/YOUR_USERNAME/swift-cli-calculator.git cd swift-cli-calculator -
Run the calculator:
swift main.swift
Example:
Welcome to Swift CLI Calculator!
Enter first number: 5
Enter second number: 3
Choose operation (+, -, *, /): *
Result: 15
swift-cli-calculator/
│── main.swift # Source code
│── README.md # Project documentation
│── .gitignore # Ignored files
- Add support for more operations (modulus, power, square root)
- Allow continuous calculations until user exits
- Format results with decimals
- Add tests
This project is open-source and available under the MIT License.