Question: java program Implement a Java program to calculate the Mathematical expressions X+y X- x*y x/y x% y All the arithmetic expressions should consist of exactly

java program  java program Implement a Java program to calculate the Mathematical expressions
X+y X- x*y x/y x% y All the arithmetic expressions should consist

Implement a Java program to calculate the Mathematical expressions X+y X- x*y x/y x% y All the arithmetic expressions should consist of exactly two operands and one operator. The two operands x and y are integers. You can assume that there is at least one blank before the operator and at least one blank after the operator. (Use the Scanner nextInt() method to read the operands and the Scanner next() method to read the operator). Echo the arithmetic expression that is calculated when giving the result. For instance, if the user enters "3 + 4" then your calculator program should output 3 + 4 = 7 Note that the user input could be erroneous in which case the expression cannot be computed). In the case of errors, give precise error messages to the user, for example: the operand is not an integer illegal operator 7 by zero IMPLEMENTATION DETAILS Use try catch blocks to handle the exceptions. Use one switch statement. Do not use any if statements'. Use as many methods as you want. Keep calculating expressions until the user indicates that s/he wants to quit. The user enters a single q' instead an operator e.g. 4q5 means quit the program Exceptions: The nextInt() Scanner method generates InputMismatchException if the input is not an integer number. If you divide a number by 0, the / and % operations throw ArithmeticException. In your program, throw IllegalArgumentException if the operator is none of (+,-./, or %)

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!