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
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!!

5 Years
Discussion Span
Last Post by Superandomness

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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.