Code challenge for sparkcentral. Applicant: Mike Roderick
The strategy for this program was as follows:
-
Create class with constructor
-
Add functions to constructor to ensure no garbage data comes through
-
Perform correct order of operations according to operator
-
Perform the actual arithmatic operations. This involves first splitting the equation into two parts: The "before-the-operator" text, and the "after-the-operator" text. An internal function is called to do the actual mathmatic operations. After the result has been achieved, simple string splitting and joining are used to re-assemble the equation.
-
Iterate over step 4 until all operations are finished.
Latest version of code currently resides at the following url: http://ideone.com/VHsAs5
The program output is at the bottom of the screen, under the "stdout" subheading.