Question: ECLIPSE Extend the Arithrmetic example from the course notes to include classes Minus, Mult and Divide. Each of these should override the sxall) method to

ECLIPSE
 ECLIPSE Extend the Arithrmetic example from the course notes to include

Extend the Arithrmetic example from the course notes to include classes Minus, Mult and Divide. Each of these should override the sxall) method to perform the correct operations. For each dass, induding the ones I've already provided, write a toString() method that returns a String containing a text version of the part of the arithmetic problem in the subtree rooted at the current node. For example, If the expression tree is calling toString() for the "node should produce the String The recommended way to do this is the same as the way the eval() method works recursively. For example, if the top node is a Plus object, it creates a String with an opening parenthesis "C", then calls its left child to return a String (which is then concatenated), then concatenates ", then calls its right child to return a string (which is concatenated), then concatenates ". The method toString) returns the resultant String. Rewrite the TestArithmetic class so that its main () method produces five random arithmetic problems of length four (i.e., having four Consts separated by three operators). Constants should be integers chosen at random in the range [1, 20). Operators should be chosen randomly from the set(+,--. For each arithmetic problem, you should print out the result of your toStringO method applied to the root node, then an equals sign, then the result of exal(), producing something like this: ((16.0/16.0)-(7.0 17.0) 118.0 ((4.0 17.0)/(12.0/12.0))-21.0 ((14.0-4.0)+ (10/20.0))-10.05 ((18.0+ 15.0)/(5.0/10.0) 66.0 ((4.0/5.0)+ (5.0 7.0) 35.8 You might find it convenient (as I did) to create methods adQpsxatox) and

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!