 |
 |
making a calculator
|
 |
|
 |
|
Moderator 
Join Date: Sep 2000
Location: Irvine, CA
Status:
Offline
|
|
I am a college student and I have to design a calculator basically in a console window and I dont have to design the thing, I just have to prompt for something and the user types what he/she wants. I only have to do multiplication. divisio. addition, subtraction, and modulus. I know how to scanf but how do I tell the program to add or subtract when I do not know what the user wants. Thanks.
|
|
{{{ mindwaves }}}
|
| |
|
|
|
 |
|
 |
|
Moderator 
Join Date: Sep 2000
Location: Irvine, CA
Status:
Offline
|
|
I dont need a calculator i just need to make one!
|
|
{{{ mindwaves }}}
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Nov 1999
Location: Georgetown, Demerara, Guyana
Status:
Offline
|
|
Hi mindwaves,
Do you mean that you need to be able to handle input strings containing arbitrary arithmetical expressions [e.g., "1+2*3/4+(5-6)"]? If so, you would probably need to use a parser-generator such as Lexx/Yacc, or to write your own full-fledged lexical analyser (grammar parser), which is not exactly a trivial task...
This takes me back to the good old days of parser algorithms, too far back to offer much direct help I'm afraid. ;-) Which CS textbook are you using? If you don't find it to be of much help, try browsing/searching for alternative ones that received good reviews at BookPool, or Amazon, etc.
When you're writing the program, if you need further assistance with a specific piece of code then post back and either I or someone else can try to help you.
Regards,
--Paul
[This message has been edited by Paul Crawford (edited 11-01-2000).]
|
|
|
| |
|
|
|
 |
|
 |
|
Moderator 
Join Date: Sep 2000
Location: Irvine, CA
Status:
Offline
|
|
Thanks for all the help but I already turned it in and I got a pretty decent score.
|
|
{{{ mindwaves }}}
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Nov 1999
Location: Georgetown, Demerara, Guyana
Status:
Offline
|
|
Hi again,
Way to go! Best wishes for your future programming endeavours. :-)
Regards,
--Paul
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|