/** 
*
* A simple calculator
*
* @author Professor David Bernstein, James Madison University
* @version 1.0
* @author Professor Elizabeth Adams, James Madison University
* @version 1.1
*/

public class Calculator
{
  public static void main (String [] args)
  {
     char 	operator;
	  int	 	leftOperand, result, rightOperand;
	  
	  try 
	  {
	        leftOperand = Integer.parseInt (args[0]);
			  operator = args[1].charAt(0);
			  rightOperand = Integer.parseInt (args[2]);
			  
			  System.out.println 
			     ("Computing :" + leftOperand +  operator  + rightOperand );

			  switch (operator)
			  {
			    case '+' :
				   result = leftOperand + rightOperand;
					break;
				
				 case '-' :
				   result = leftOperand - rightOperand;
					break;
					
				 case '/' :
			      result = leftOperand / rightOperand;
					break;
				
				 default :
				   result = 0;
				} // end switch
				
			  System.out.println ("Result: " + result);	
		 } // end try
		 
		 catch (ArithmeticException ae)
		 {
		    System.out.println (" does not compute!");
		 }
		 catch (NumberFormatException nfe)
		 {
		    System.out.println (" Non-numeric operand ");
		 }
	} // end main
} // end class	 	   
				