Archived

This topic is now archived and is closed to further replies.

Ada Help Needed

This topic is 5014 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Looking at the example code, I''m trying to make a few changes and have no clue how to do it. Basicaly, this is a CLI (Command Line Interface) Calculator. You punch in an equation and it spits out an answer. I''m trying to get it to store calculations as well as print them out in numerical order according to their result, like so:
2
+
1=
1+1+2=
4 * 4=
^D
2 + 1 = 3
1 + 1 + 2 = 4
4 * 4 = 16
 
Answers aren''t printed out until ^D (EOF) has been reached. I''m just having problems doing those last few things with the code I have. Any help is appreciated. Download example source: http://forums.extremeoverclocking.com/attachment.php?attachmentid=32848

Share this post


Link to post
Share on other sites
I should also mention that support for multiple equations is needed...currently the program is only printing out the answer to one. Also, it is not requiring an equal symbol at the end of an equation but it needs to...

ie, if I run it now:
input:
5 + 5
output:
10

What I''m trying to do:
input:
5 + 5 =
1 + 4 =
7 * 2 =
output:
1 + 4 = 5
5 + 5 = 10
7 * 2 = 14

Share this post


Link to post
Share on other sites
You''re gonna have to add each equation to some sort of list as you go along. Then sort it by the answer at the end before you output it. As for requiring an equals symbol, well, that''s a lot of files in that zip, and in a language most of us won''t understand. It might help if you were able to post the specific part that handles the input.

[ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]

Share this post


Link to post
Share on other sites