Coding a Scientific calculator (Console based)

Hello

As part of a personal project, I need to make a console based Scientific calculator.

It needs to be able to add, subtract, multiply and divide a large amount of numbers per command (eg: 2+2+2+2+2+2*9/7*sin 45- 88.277) and be able to manipulate numbers correctly using BIDMAS.

It needs to be able to compute trigonometry functions, logarithms, mod of an integer, calculate factorials and calculate exponents and roots to the nth degree.

How can I go about doing this and how many lines of code will it take?

I do not want it to have a GUI at the moment.

Any source code will be released and the entire program will be free.


I have looked around for ages and all I can find are calculators which can only add two numbers
Last edited on
Bump
Do you actually need/want to code it yourself? Or would pre-existing code be ok?

You see, if you want some code which evaluates a string like "2+2+2+2+2+2*9/7*sin 45- 88.277" and returns the answer, then there are a number of libraries which are already available.

Of course, it depends on the point of your personal project. If you want to develop you're own expression evaluator, then these existing libraries will be of no use.

But if the focus of your project is elsewhere, and a library would be of use, then the open source muparser library might be of interest to you:
http://en.wikipedia.org/wiki/MuParser
http://muparser.sourceforge.net/

Andy
Last edited on
This looks excellent! Thanks a load!
Hey I downloaded the library too. Can someone please tell me how to connect it to the compiler so its as easy to read as iostream, cmath, string, ect? Should I just taking the files from the "include" folder I download and put them in the "include" folder where to other standard libraries are stored or do I need the other files that can with the download and if so, where should I put them?
Could do that, or you can tell the linker of your respective IDE to find it wherever you want to put the files.
how do I do that? I have a very brief (basic) understanding of linkers. I just thought they were a step the computer (or compiler) deals with on its own when turning your program into an .exe file.
Last edited on
Yeah, I couldn't figure out how to use the Library either. I am using the Code::Blocks IDE
Bump
Topic archived. No new replies allowed.