Skip to content

Latest commit

 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PolyCalc (short for Polyglot Calculator)

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.


Features

  • 🧮 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.

Languages Implemented

  • Python
  • C
  • Go
  • TypeScript
  • JavaScript
  • Bash
  • C++
  • PowerShell
  • PHP
  • MATLAB

Getting Started

Follow the instructions below to run the calculator in your preferred language.

Python

  1. Install Python 3.x.
  2. Run the program:
    python simple_calculator.py

C

  1. Use GCC to compile:
    gcc simple_calculator.c -o simple_calculator
  2. Run the program:
    ./simple_calculator

Go

  1. Install Go.
  2. Run the program:
    go run simple_calculator.go

Typescript

  1. Install dependencies: (shown wrt pnpm as i used it for this project)
    pnpm install
  2. Compile the code:
    pnpm tsc
  3. Run the compiled code:
    node simple_calculator.js

Javascript

  1. Run directly with Node.js:
    node simple_calculator.js

Bash Shell

  1. Make the script executable:
    chmod +x simple_calculator.sh
  2. Run the program:
    ./simple_calculator.sh

C++

  1. Use G++ to compile:
    g++ simple_calculator.cpp -o simple_calculator
  2. Run the program:
    ./simple_calculator

PowerShell

  1. Make the script executable:
    Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
  2. Run the script:
    .\simple_calculator.ps1

PHP

  1. Run the PHP script using the PHP command line:
    php simple_calculator.php

MATLAB

  1. Open MATLAB by launching the MATLAB application
  2. Navigate to the Script’s Directory
  3. Run the MATLAB script:
    simple_calculator

Project Structure

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

Contributing

Contributions are welcome! If you’d like to add more languages or features:

  1. Fork this repository.
  2. Create a new branch:
    git checkout -b feature/new-language
  3. Commit your changes:
    git commit -m "Add [language] implementation"
  4. Push to the branch:
    git push origin feature/new-language
  5. Submit a pull request.

License

This project is licensed under the MIT License.

About

"PolyCalc (Polyglot Calculator) demonstrates core programming concepts across multiple languages, embodying the simplicity and versatility of a calculator as the perfect ‘hello world’ program for learning any new language.”

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages