5
Contributors
4
Replies
20
Views
3 Years
Discussion Span
Last Post by gusano79
0

Do you mean you need a program that can accept inputs in the style of your example and correctly determine the value?
I would separate the string on the mathmatical operators (+,-,x, /) and bracket, then use the BODMAS rule to figure out the order for which the operations take place.
But your question is unclear. Am I on the right track?

0

It is a matter of operator precidence. Multiplication and division are of equal precidence, as are addition and subtraction. Multiplication and division have higher precidence than addition or subtraction. Therefore, you must put the desired expressions inside parentheses. IE: (2*5/6+3-8*3/2) would be likely equivalent to ((2*5)/6)+3-((8*3)/2). Is this your intention? Other possibilities could be (2*(5/6))+((3-8)*(3/2)). There are other permutations that could be applied, and in most cases the results are very different.

Edited by rubberman

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.