Hi there,

I'm making a simple C++ calculator. I want it to work something like this sample run:

Begin Calculations
10 S // Set Accumulator to 10
= 10.000000 // Contents of Accumulator
2 / // Divide by 2
= 5.000000 // Contents of Accumulator
55 - // Subtract 55
-50.000000
100.25 S // Set Accumulator to 100.25
= 100.25000
4 * // Multiply by 4
= 401.000000
E // End of Program
= 401.000000
End of Calculations

I made methods for all of the actual actions of dividing and multiplying, etc.
I'm more confused about taking in my user's input. Should I take it as a string and parse it? Is there a way for them to input the symbol and number and both would result in a "symbol" variable and a "number" variable, and if it's wrong there is an error?

I'm fairly new to C++ so any help you can give me would be great.

Thank you!!

you can use the C method scanf. so you can read a number followed by a character followed by another number. You can´t read an operator, it would be like reading a function, impossible.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.