An open API service indexing awesome lists of open source software.

https://github.com/123aiden-g/swift-cli-calculator

A simple command-line calculator written in Swift. My first Swift project.
https://github.com/123aiden-g/swift-cli-calculator

beginner-friendly calculator cli learning project swift

Last synced: 8 months ago
JSON representation

A simple command-line calculator written in Swift. My first Swift project.

Awesome Lists containing this project

README

          

# Swift CLI Calculator

![Swift](https://img.shields.io/badge/Swift-FA7343?style=for-the-badge&logo=swift&logoColor=white)

A simple command-line calculator built in Swift.
This is my first Swift project — a small but fun way to learn the language.

---

## Features
- Basic arithmetic: addition, subtraction, multiplication, and division
- Input validation (handles invalid numbers and division by zero)
- Clean CLI interface
- Easily extendable for new operations

---

## Usage

1. Clone the repository:
```bash
git clone https://github.com/YOUR_USERNAME/swift-cli-calculator.git
cd swift-cli-calculator
```

2. Run the calculator:
```bash
swift main.swift
```

**Example:**

```
Welcome to Swift CLI Calculator!
Enter first number: 5
Enter second number: 3
Choose operation (+, -, *, /): *
Result: 15
```

---

## Project Structure
```
swift-cli-calculator/
│── main.swift # Source code
│── README.md # Project documentation
│── .gitignore # Ignored files
```

---

## Roadmap
- Add support for more operations (modulus, power, square root)
- Allow continuous calculations until user exits
- Format results with decimals
- Add tests

---

## License
This project is open-source and available under the MIT License.