0
I can't use Point (Float) Numbers in my calculator (C++)
Problem is that I'm working on Updating my 11 months old Calculator written in C++ and It's mostly all done. I can divide smaller numbers bigger (2 / 4 = 0.5). One problem that occured is i can't + two point numbers (0.5 + 0.5 results in Error) or - two point numbers or * two points numbers so I ask here for some help. Thanks in advance Script: https://code.sololearn.com/cyqTln6peslH/?ref=app
4 Réponses
+ 4
You get the error because you accept 0.5 as integer, in which case only the zero will be assigned into variable "a", afterwards you have "garbage" value in the input stream, which makes your code assign the digit separator (.) as your operator "op" here on, your switch statement sees that user had typed an invalid operator and refuse to process the data (show error message).
+ 1
Thanks a lot! Both of you. Thanks Mohamed for fixing it and Ipang for moe info about this stuff.
0
Can you tell me more please? At least little insight how to do it.
0
Thanks fot help! Gonna check it and give some info. Also is there way to convert int to float?