hello all.....
i was asked to perform a program of a calculator using stacks........
so i'll be so glad if any one have any simple ideas that helps...we need to read equations from the keyboard or files with no spaces in between, we must separate the numbers from the operators but realize the numbers that consists of different digits.. and make the postfix of the equation to figure out how to calculate the result and then print it.....


share your ideas......what do you think.......
thanx

>share your ideas......what do you think.......
I think you're not going to get anyone to tell you how to do this. It's your assignment after all. Start by figuring out how to read an expression from the input stream. You need to be able to build an integer from multiple consecutive digits and recognize operators. Once you can do that it's a simple matter of using the stack to evaluate the expression using polish notation: pop an operator, pop the operands, do the operation, push the result.

is it bad to ask?????
i know its my assignment..and all i asked for is ideas from people like you.....
any way thanx alot ..... :D

>is it bad to ask?????
It's bad to ask a question that amounts to "Please do my work for me".

why are you so upset Narue !!? simple ask it was no need to be so mean.

well for that you should first figure out how to read the your equation, a string should do it. try to separate the numbers from the operators but be careful with the neg numbers( such as 2*-3 ). then use an empty stack to get the get your postfix expression --> If the scanned character is an operand, add it to the Postfix expression... other wise check the operator with its precedence in the stack ( of course as long as the stack isnt empty.

later on use the stack again to get your result ---> if the scanned character from your postfix expression is an operand, add it to the stack. If the scanned character is an operator, there will be at least two operands in the stack, so you perform the operation and push the result into the stack ( dont forget to pop the two operands first ).
keep doing that until you read all your postfix expression and finally you will have one element in the stack which will be your result.

>why are you so upset Narue !!?
I'm not, you're just too sensitive.

>simple ask it was no need to be so mean.
To be perfectly frank, you're in no position to lecture me on your first post.

>[snip description of the solution]
I'm curious why you chose to wait three days and then post essentially the same thing someone else did earlier in the thread.

I'm not, you're just too sensitive.
me too sensitive!! ... it isn't my thread in the first place.
To be perfectly frank, you're in no position to lecture me on your first post.
it may be my first post on this site, but it isn't the first in my life.

i didnt wait 3 days to reply, i registered to this site today and it happens that i have converting from infix to postfix as an assignment also, so shared ideas.

it seems we went off topic.

guys....hold on
thanx alot for both of u
naure i know well that this is my assignment ... and iam working on it....i did not say "do my work for me"...all i asked for is a help fro proffitional people like u .. and i guess this is not a mistake....
iam doing my best and working on .... thanx alot for both of u
by the way naure .... my older brother had the same project when he was at my age ... w both study the same topics... if i ever wanted any one to do my work .. i could easily took his code from his pc...
thanx alot... both

>me too sensitive!! ... it isn't my thread in the first place.
So you go around playing net nanny on other people's threads? ;)

>it may be my first post on this site, but it isn't the first in my life.
Then you know that talk is cheap. I know nothing about you, so you mean nothing to me.

>it seems we went off topic.
It happens. Often the off-topic topics are more interesting and/or informative than the on-topic topics. Sometimes it's an entertaining pseudo flame war, sometimes it's a technical tangent, and sometimes it's a highly advanced debate between gurus. Just go with the flow and you'll have more fun. :)

Bah, I hate having to make consecutive posts.

>i did not say "do my work for me"
I know, but generally when people ask for "ideas", they're looking for more than a push in the right direction. I wanted to make it clear that your work is your work, and while we'll help, the lion's share of effort should be on your end. Think of it as a friendly reminder rather than an attack.

I treated my second reply as a general answer to an unrelated question, so just pretend you asked that question out of context and you'll understand my intentions.

may be generaly ... but not on my case.... i said thanx many times.....
i took every word of u sooooooooo friendly ... why shouldn't i!!!!!
am working.. and i know well that if i'll need help i'll got it from diff. places
forget this topic.. i guess u have more important things to do in ur life.... at least more important than me.....
and thaaaaaaaaaaaaaaanx ..... take all this friendly too:cool:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.