Giter Site home page Giter Site logo

mgumbo / postfix-calculator Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 12 KB

Files for a calculator that converts infix notation to postfix, and then evaluates the expression.

License: MIT License

C++ 100.00%
infix postfix calculator postfix-calculator c-plus-plus

postfix-calculator's Introduction

Postfix Calculator

Files for a calculator that converts infix notation to postfix, and then evaluates the expression.

NOTE

This calculator uses a custom stack class (Mystack) that is defined in another repository.

USAGE

Expressions are entered in the standard infix notation and will be evaluated with the standard PEMDAS order of operations. Spaces can be entered into the expression as desired and will not affect the result. For example:

1 + 2 - 3 * 4 / 5

      and
      
1+2-3*4/5

are evaluated in exactly the same way and will produce the same result. However, numbers with spaces in between them will ALWAYS be treated as separate numbers. For example:

1 + 23 * 4 / 5

    and

1 + 2 3 * 4 / 5

will not be treated the same (in fact, the second expression will be read as an incorrect input).

Incomplete expressions will are not properly able to be evaluated and will generate a default result of 0. For example:

1 + 2 - 3 * 4 / 5 +

will not be evaluated properly.

Group operations are allowed, but only via parenthesis. For example:

(1 + 2) - 3 * 4 / 5

Groups in parenthesis will be evaluated prior to any other operations.

Parenthesis must be placed and closed properly in order for an expression to be evaluated. For example:

(1 + 2 - 3 * 4 / 5
1 + 2) - 3 * 4 / 5
((1 + 2) - 3 * 4 / 5
1 + 2 - (3 * 4 / 5)))

will all fail to evaluate and prompt the user to enter the expression again.

postfix-calculator's People

Contributors

mgumbo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.