+ 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.

21st Nov 2017, 3:38 PM
Geena Nana
Geena Nana - avatar
1 Answer
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!
21st Nov 2017, 11:45 PM
Mohammad Nasouri
Mohammad Nasouri - avatar