Hi guys, I am learning C++ from Stroustrup's book and there is this "try this" in chapter 4... It says to try to write a programm that can convert euros, yens or pounds in dollars... My problem is: when my input is like "23y", "3p", "23 y", "3 p" or "877 e" everything is fine but I can't understand why the output is "Incorrect input" whe I enter values like "56e"... Can you explain it to me?? ty.
maybe try instead to assign it to a string , which you would compare the last character wether is e,y,p , then take the string from 0 to string.size() -2 and convert to a double , then you do the conversion for currency. There is other option as well.
56e could be construed as a double, doubles can have this format: 56e3 which is 56'000 . So your money (56e) is still 56, but there is now no value for coin :+)
You could prompt for the two values separately if that fits in with the requirements.