| ogranatw (19) | |
|
I am a beginner and I need help writing a calculation program. The program should be able to handle at least 8 operators, square, sin, cos, tan, powers, +, -, *, /. The program should be able to handle all these things in one expression. For example: v for square, s for sin, c for cos, t for tan and ^ for power. v(s3.4/5^8). T he program needs to understand parenthesis. And square, sin, cos and tan should be used as a "prefix" (executed on the following operator). And when '=' is put in the result is written out, the program resets and restarts. And if you could put in some comentaries in the code, so I know waht you've dont. It would be very helpful for the future. Please help me!!! Thank you | |
|
Last edited on
|
|
| Duoas (6734) | |
|
Unfortunately, no one here is going to do your homework for you. I don't know why CS 101/102 professors continue to give this as homework. It is not a particularly simple thing to do. You might want to google around "recursive descent". Good luck. | |
|
|
|
| Graham (15) | |
|
It is NOT simple, at all. For a while, I've tried to do this, and have never succeded... If you get a clue, contact me. I'd love to know. PS: See the book listed in my Bio, it has an exercise after chapter 12 describing how to do this in detail. | |
|
|
|
| mezosoft (13) | |||
|
hello i'm mo3taz from egypt, i,ve solved this problem but just for the operators +,-; example input: 1+2+3-2+3-4+5. out put: the result don't forget the fullstop at the end
if there is any problem with this tell me , and i'll try to insert other operators my e_mail is : mo3taz_kilany@hotmail.com | |||
|
Last edited on
|
|||
| wooden nose (2) | |||
|
There is a way to solve this problem with a recurive descent: I have *fully* copied this code from Arnold Willemers page (http://www.willemer.de/informatik/cpp/rekursion.htm) But you can also find it in one of his books.
its in german, sorry for that :) It loops trough all token and looks what it is and then calls the needed function. Hope it helps wooden nose | |||
|
Last edited on
|
|||
| ogranatw (19) | |
| Thanks for your help, you've been vary helpful. | |
|
|
|