ExpressionCalculator.java.html

  1  import java.util.Scanner;
  2  
  3  /**
  4     This program calculates the value of an expression 
  5     consisting of numbers, arithmetic operators, and parentheses.
  6  */
  7  public class ExpressionCalculator
  8  {
  9     public static void main(String[] args)
 10     {
 11        Scanner in = new Scanner(System.in);
 12        System.out.print("Enter an expression: ");
 13        String input = in.nextLine();
 14        Evaluator e = new Evaluator(input);
 15        int value = e.getExpressionValue();
 16        System.out.println(input + "=" + value);
 17     }
 18  }