Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > making a calculator

making a calculator
Thread Tools
Moderator
Join Date: Sep 2000
Location: Irvine, CA
Status: Offline
Reply With Quote
Oct 24, 2000, 08:47 PM
 
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 }}}
     
Blobby
Guest
Status:
Reply With Quote
Oct 29, 2000, 03:32 PM
 
Check out Calc1
     
Moderator
Join Date: Sep 2000
Location: Irvine, CA
Status: Offline
Reply With Quote
Oct 29, 2000, 08:05 PM
 
I dont need a calculator i just need to make one!
{{{ mindwaves }}}
     
Dedicated MacNNer
Join Date: Nov 1999
Location: Georgetown, Demerara, Guyana
Status: Offline
Reply With Quote
Nov 1, 2000, 06:53 AM
 
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
Reply With Quote
Nov 2, 2000, 12:51 PM
 
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
Reply With Quote
Nov 6, 2000, 03:42 AM
 
Hi again,

Way to go! Best wishes for your future programming endeavours. :-)

Regards,

--Paul
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 11:01 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2