+ 2
How to do the evaluation part(HELP)
public static Rational parse(String str) public static Rational evaluate(String[] expr) parse takes a String (e.g. "3/16") and returns a Rational object. evaluate takes an array of Strings (e.g., "3/16", "+", "5/8"), converts the first and the third Strings to Rational objects, adds them to create a new Rational object, and returns that object.
1 ответ
0
You have 2 ways to do this, I think!
1. if your rational object able to do operations then you can simply parse objects and just do the math! (I dont have any idea how you created the Rational class)
2. Use regex or string methods to get the numerator and denominator, since you get them you need to find the result, afterwards simply parse the calculated numbers.
I hope, I could pass my words.
Good luck!