it is me, again...
this time i have to write a Postfix-Notation by using stacks.
I have to calculate (3+4) * 5 and this is in Postfix Notation 3 4 + 5 *
i kind of know how I have to do it... but i have problems to write it.
Just thought that I will write down my ideas and maybe someone can help me to put it into proper Java-Code, that would be really nice:
1) first i need to put the 3 4 + 5 * into an array. so lets say it is already in the array arithm = 3
arithm = 4
arithm = +
arithm = 5
arithm = *
2) i need to do a for loop i think with
for(int i = 0; i < arithm.length; i++)
3) now i need a condition, so that it is putting the numbers on a stack, but only the first two... so i did the class stack already with the methods push (putting a number on the stack, and pop, giving out the last element)
if(arithm[i] != operandor)
i actually don't know exactly how to write this condition...
4) now i don't know how to carry on...
it would be lovely if anyone could help me...