A basic way:
1) Read the input
2) Divide the input in logical pieces (numbers and operators)
3) Use something for order all operations from their precedence and associativity (at example 2+3*5 is equals 3*5 = 15 + 2= 17) if do you want (usually is made by using a tree ds)
4) perfom the operations
I tried code evil function you can see
here you define the keywords and if matches it search for the number after that it excite function define in the code.
Sonic not necessarily, if you create a lexical analyzer. you can calculate multiple mathematical expressions in one line with the use of stacks by changing them into a postfix notation.
KrOW explained a part of how this was done with the PEDMAS method to correctly structure the expressions.
this is usually how calculators and machines calculate multiple expressions.
here is a link on how it's done.
I did a similar calculator some days ago in c++
The logic is pretty simple, when you perform a calculation the result will be affected by the next calculation and so on...
Example: (2*3+5) 2*3=6, 6+5=11...
Here's the code anyway:
I don't know why this in sololearn doesn't work, but if you use others ide, it works