-2

I want to create a mathematical calculator in objective-C. I need it to run through a command line. The user will enter an equation like 4 + 2 * 12 etc. The output should calculate the 2 and 12 first because they are times by. How would I create a command line program that creates output based on mathematical order or precedence. for example solving whats in the brackets first then anything that is multiplied and or divided by etc etc.

bunsworth
  • 1
  • 3
  • Either try to solve the problem by thinking or [search for existing approaches](https://www.google.de/search?q=calculator+objective+c&ie=utf-8&oe=utf-8&client=firefox-b-ab&gfe_rd=cr&ei=xXbvWIKqCcjb8Aemn6iABA) for your homework. – shallowThought Apr 13 '17 at 13:03
  • Possible duplicate of [How to evaluate the string equation in ios](http://stackoverflow.com/questions/16785873/how-to-evaluate-the-string-equation-in-ios) – Amin Negm-Awad Apr 13 '17 at 13:21

1 Answers1

1

there are multiple programs available online for this here is just one http://www.wikihow.com/Make-a-Command-Prompt-Calculator, in the CMD line you can specify precedence by simply using parenthesis like the following C:> set /a ((2*12)+4) obviously replacing hard coded values with that passed to a variable.

jimmy8ball
  • 746
  • 5
  • 15