Explore BrainMass

Explore BrainMass

    Java program to parse an arithmetic expression

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    Write a Java program that takes as input an infix arithmetic expression then transforms it to a postfix expression and based on a binary tree, it evaluates that expression. For instance, the program takes the following infix expression: (1 + 2) * (3 - 4) / (1 + 2) then transforms it to a postfix expression: 1 2 + 3 4 - * 1 2 + / and then stores it in a binary tree. After that, your program should do the opposite: traverse the binary tree and print out the arithmetic expression in infix format.

    © BrainMass Inc. brainmass.com October 10, 2019, 7:03 am ad1c9bdddf

    Solution Summary

    The solution shows how to parse an expression in Java.