Start New Discussion within our Software Development Community

Hello everyone. I am University of Bath Computer Information Systems student and i have to submit a java calculator. As far as i am quite new to java i would like to kindly ask you for some help with it.
Here is my task: Write a program that takes as input a mathematical expression consisting of decimal numbers and the four basic mathematical operations (+,-,/-*) and nested mathematical expressions and evaluates this expressions:
5+6*2 results in 17
(5+4)*(4-2) results in 18

Please help me with this if t is possible. I have no idea how to start it, i tried some solutions like taking the entire mathematical expression as str input and than breaking it into 2 arrays one for numbers and one for operators, but nothing .... Please help me with some lines of code if you have time, if not just give me any ideas that comes to your mind. Much appreciated.

Hi,

You can convert the infix expression
5+6*2
to postfix
5 6 2 * +
then compute it.

Here are the algorithms for conversion link
and for evaluation link

GL

This question has already been answered. Start a new discussion instead.