Question: In this question, you will write a Java program that calculates special arithmetic expressions. These expressions start with either + or *. Then, 3

In this question, you will write a Java program that calculates special

In this question, you will write a Java program that calculates special arithmetic expressions. These expressions start with either + or *. Then, 3 positive integer numbers follow them separated by commas and enclosed in parenthesis. Depending on the operation given at the start of the expression, either you sum up or multiply all the numbers inside the parenthesis. For example, +(2,3,4) is a special arithmetic expression and its result is 9 (2+3+4=9). Here are two other examples: the expression +(30,1,22) is equal to 53 and the expression *(12,2,2) is equal to 48. Your program must ask the user to enter the special arithmetic expression and output its result. You can use nextLine() method of the Scanner object to read the expression as input. You can use the method Integer.parseInt() in order to convert a string representation of an integer to its integer value. Here are some sample runs: Enter an expression: +(2,3,4) The result is 9. Enter an expression:* (10,21,2) The result is 420. Enter an expression: +(2,31,1002) The result is 1035. Enter an expression: * (2,3,2) The result is 12.

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 Programming Questions!