Part 1: (Evaluate expression)
Modify code below to add operators ^ forexponent and % for modulus.
For example, 3 ^ 2 is 9 and 3% 2 is 1.
The ^ operator has the highest precedence andthe % operator has the same precedence as the* and / operators. Your programshould prompt the user to enter an expression.
- Sample output:
package Collection_Ch20;
import java.util.Stack;
public class EvaluateExpression {
public static void main(String[] args) {
// Check number of argumentspassed
if (args.length != 1) {
System.out.println(“Usage: java EvaluateExpression”expression””);
System.exit(1);
}
try {
System.out.println(evaluateExpression(args[0]));
}
catch (Exception ex) {
PayPal Gateway not configured
PayPal Gateway not configured