how do i make a calculato in c++??

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
gamedudex
Insane DCEmu
Insane DCEmu
Posts: 238
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Sun Jul 21, 2002 6:37 pm
Location: USA
Has thanked: 0
Been thanked: 0

how do i make a calculato in c++??

Post by gamedudex »

i'm trying this out...i found some infor online using ask jeeves...not helping enough..

how do i make an 8 function calculator in c++ that performs addition, subtraction, multiplication, division, exponentiation, base-ten logarithm, factorial, and quit operations?
BlackAura
DC Developer
DC Developer
Posts: 9951
Joined: Sun Dec 30, 2001 9:02 am
Has thanked: 0
Been thanked: 1 time

Post by BlackAura »

The actual calculation bit is quite easy, but the hard part is the interface. I'll have a look around, and see what I can find.
Tangent
DC Developer
DC Developer
Posts: 100
Joined: Fri Jan 17, 2003 3:01 pm
Location: Pits of Insanity
Has thanked: 0
Been thanked: 0
Contact:

Post by Tangent »

Is this for your homework again? Be honest, now.
There are 10 kinds of people in the world: those who understand binary, and those who don't.
User avatar
toastman
Iron Fist of Justice
Iron Fist of Justice
Posts: 4933
Joined: Sat Nov 10, 2001 3:08 am
Location: New Orleans
Has thanked: 0
Been thanked: 0
Contact:

Post by toastman »

BlackAura wrote:The actual calculation bit is quite easy, but the hard part is the interface. I'll have a look around, and see what I can find.
You could do a command line interface that would be quite simple or if you knew some basic Windows programming you could make one with that. (I have a book on Win98 programming that has an example which makes a calculator using the dialog boxes. O_o)
No signature.
gamedudex
Insane DCEmu
Insane DCEmu
Posts: 238
Joined: Sun Jul 21, 2002 6:37 pm
Location: USA
Has thanked: 0
Been thanked: 0

Post by gamedudex »

Tangent wrote:Is this for your homework again? Be honest, now.
no, i just saww this problem and i wanted to try it out
Mask of Destiny
Mental DCEmu
Mental DCEmu
Posts: 330
Joined: Sun Mar 23, 2003 10:52 pm
Has thanked: 0
Been thanked: 0

Post by Mask of Destiny »

If it's going to be command-line based you could be slick and parse out a complex expression and do order of operations. Easiest way to do that is to convert it from infix (2 + 3) to postfix(2 3 +) and then calculate.
BlackAura
DC Developer
DC Developer
Posts: 9951
Joined: Sun Dec 30, 2001 9:02 am
Has thanked: 0
Been thanked: 1 time

Post by BlackAura »

toastman wrote:
BlackAura wrote:The actual calculation bit is quite easy, but the hard part is the interface. I'll have a look around, and see what I can find.
You could do a command line interface that would be quite simple or if you knew some basic Windows programming you could make one with that. (I have a book on Win98 programming that has an example which makes a calculator using the dialog boxes. O_o)
Which, compared to "answer = first + second", is quite complex. :P

If you want it to work like a proper calculator, you need some way to parse the input, and decide what you want to do.
User avatar
toastman
Iron Fist of Justice
Iron Fist of Justice
Posts: 4933
Joined: Sat Nov 10, 2001 3:08 am
Location: New Orleans
Has thanked: 0
Been thanked: 0
Contact:

Post by toastman »

For command line you need two things.

Binary trees
Reverse polish notation

I've said all I need to.
No signature.
AmadeusZull
Soul Sold for DCEmu
Soul Sold for DCEmu
Posts: 4085
Joined: Wed Oct 17, 2001 7:44 pm
Location: NYC
Has thanked: 0
Been thanked: 0
Contact:

Post by AmadeusZull »

search for stack calculators in c++. you should find many many old assignments.
Image

I am no longer an ACE@ite. Never will I kiss his feet is what I don't. And that I don't, is good I do.
Post Reply