Question: Use java to solve this problem: Write a program that takes a single line of input, representing an arithmetic expression. The expression will consist of

Use java to solve this problem:

Write a program that takes a single line of input, representing an arithmetic expression. The expression will consist of numeric digits (0-9), the plus operator (+) and the multiplication operator (*). The given expression will be a valid arithmetic expression (ie. "*2++" is not valid).

Your task is to evaluate the arithmetic expression, following the normal rules of operator precedence, and print the result without any leading or trailing whitespace.

The resulting numbers will fit in a normal integer.

Note: Solutions such as "eval()" in python are elegant, but not what we are looking for here. Please evaluate the expressions with your own code :).

Example Input

20+2*3

Example Output

26

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!