Fraction Processes

closed account (365X92yv)
I'd like to input a fraction, i.e 1/2 +3/4 and get the result of that. Whats the best method for reading the input?
Try using getline into an std::string.
closed account (365X92yv)
If I read into a getline though, how do I read the operand for the fractions and then how do I read the string?
You just have to parse the string. It's a useful skill :) Iterate through each character and do something different depending on if its a plus or minus sign, and the likes. Also, my advice would be to take your fractions and convert them to decimals so you can easily perform operations with them.
Last edited on
Topic archived. No new replies allowed.