Monday, August 1, 2016

Simple Calculator with Order of Operations in C#



Here is the Calculator with order of operations for multiplication, division, addition, and subtraction. No parenthesis, exponents, or other things included. This is using the tree method. We check for the operation that would be done last from right to left, and this is the first node of the tree. Keep in mind: "multiplication and division are of equal precedence, as are addition and subtraction." Here is an example of how the tree works:
Source: http://math.hws.edu/eck/cs225/s03/binary_trees/expressionTree.gif

This is the Program.cs file below.



This is some class file, for ex. Calc.cs below: