Using a switch statement based on the operator, evaluate the expression.

When complete, the result variable should contain the result of the expression.

The operator generally corresponds to the Java operator, i.e. "*" for multiplication.

One exception is the "^" operator, which requires special handling.

The "^" operator is exponent, which raises the first operand to the power specified by the second operand.

By far the easiest way to implement the exponent operator is using Math.pow().

Several examples of input expressions and the return strings are shown below.

Use the Double wrapper class to convert the numerical result to a string, for example:

CODE: String returnString = Double.toString(result);

Return the converted string, thereby exiting the method.

You do not have to close the Scanner, but you can if you want to.

Sample Output

The code you are writing is integrated into a graphical user interface (application)
for a desktop calculator. To use the Calculator, run the main method in
Calculator.java.
Enter a number, an operator, another number, then press the equals sign. Examples
of the correct output are shown below:

Expression (input string)

Result (return value)

"11.22 + 3.456 = "

"14.676 "

"5.555 - 32.14 = "

"-26.585 "

"25634.8 * .32 = "

"8203.136 "

"2.1 / 55.3377 = "

"0.037948812473232535 "

"12345 % 23 = "

"17.0 "

"5 ^ 4 = "

"625.0 "

"Whatever + 2 = "

"Invalid Operand! "

"4.0 - 1.2.3 = "

"Invalid Operand! "

"1.234 $ 0.5 = "

"Invalid Operator! "

Specifications

Work on your own, as always.

The name of the source code file must be exactly

P3.java

Name the file exactly - upper and lower case matters!

Comments at the top as shown above.

Assignments should be implemented using Eclipse.

Assignments should be implemented using Java, version 1.8.

Make sure your code runs on machines in the CSB 120 lab.

Turn in through the Checkin portal.

Read the syllabus for the late policy.

We will be checking programs for plagiarism, so please don't copy from anyone else.

Grading Criteria

100 points for perfect submission.

0 points for no submission, will not compile, submitted class file, etc.