Hello, I'm trying to make a post-fix calculator with stacks, And im running into problems with the input, The method I'm showing here is the way I want to do it,(I dont want to use getine() ) but I do not think I am going about it right, Or maybe I am, I dont have the push/pop functions set up yet.
I think There needs to be a different loop, but I am not 100% sure on how to execute this, Thank you.
What do you expect the input to look like? Are you just reading a single line or do you plan to read multiple lines? Can one line contain multiple operations?
Your program must read a single equation from standard input. The operators are + - * / ^ (^ is power, 2 4 ^ is 2 raised to the power of 4). Numbers can be any double number, for example 4, 4.2, .2, 0.2, 0000.233. You can assume that the number is small enough to fit into a double variable (I won't give you a number with 200 digits).
Your program should ignore all white space (spaces, tabs, newlines).
If two numbers are in a row, there must be a space between them. For example, 42 is the number forty-two, and 4 2 are the numbers four and two.
There do not have to be spaces between numbers and operators. For example, 10 10+ is a legal equation.
There do not have to be spaces between two operators. For example, 10 10 10++ is a legal equation."
OK. The only problem I see with your code so far is that you won't parse ".2" correctly. As you mention, you still need to do the stack part and you need to implement the operations.