PolyCalc is a multi-language arithmetic calculator project aimed at mastering the basics of various programming languages. The project implements a simple calculator in multiple languages, including Python, C, C++, Go, TypeScript, JavaScript, Bash, PowerShell, PHP and MATLAB demonstrating the fundamentals of input handling, arithmetic operations, and formatted output.
- 🧮 Performs basic arithmetic operations: addition (
+), subtraction (-), multiplication (*), and division (/). - ✅ Input validation for numbers and operators.
- 🎯 Displays results with two decimal precision.
- 🛠 Modular and structured code for each language, showcasing best practices.
- Python
- C
- Go
- TypeScript
- JavaScript
- Bash
- C++
- PowerShell
- PHP
- MATLAB
Follow the instructions below to run the calculator in your preferred language.
- Install Python 3.x.
- Run the program:
python simple_calculator.py
- Use GCC to compile:
gcc simple_calculator.c -o simple_calculator
- Run the program:
./simple_calculator
- Install Go.
- Run the program:
go run simple_calculator.go
- Install dependencies: (shown wrt pnpm as i used it for this project)
pnpm install
- Compile the code:
pnpm tsc
- Run the compiled code:
node simple_calculator.js
- Run directly with Node.js:
node simple_calculator.js
- Make the script executable:
chmod +x simple_calculator.sh
- Run the program:
./simple_calculator.sh
- Use G++ to compile:
g++ simple_calculator.cpp -o simple_calculator
- Run the program:
./simple_calculator
- Make the script executable:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
- Run the script:
.\simple_calculator.ps1
- Run the PHP script using the PHP command line:
php simple_calculator.php
- Open MATLAB by launching the MATLAB application
- Navigate to the Script’s Directory
- Run the MATLAB script:
simple_calculator
The project is organized into the following directories and files:
PolyCalc/
├── Python/
│ └── simple_calculator.py
├── C/
│ └── simple_calculator.c
├── C++/
│ └── simple_calculator.cpp
├── Go/
│ └── simple_calculator.go
├── TypeScript/
│ └── simple_calculator.ts
├── JavaScript/
│ └── simple_calculator.js
├── Bash/
│ └── simple_calculator.sh
├── PowerShell/
│ └── simple_calculator.ps1
├── PHP/
│ └── simple_calculator.php
├── MATLAB/
│ └── simple_calculator.m
├── README.md
└── .gitignore
Contributions are welcome! If you’d like to add more languages or features:
- Fork this repository.
- Create a new branch:
git checkout -b feature/new-language
- Commit your changes:
git commit -m "Add [language] implementation" - Push to the branch:
git push origin feature/new-language
- Submit a pull request.
This project is licensed under the MIT License.