public static String calculate(String expression,boolean useDegree,int decimalPlaces){

		useDegrees = useDegree;

		try {
			//Parse
			Vector<Token> tokens = Parser.tokenize(expression);

			tokens = Parser.convertToPostfixTokens(tokens);

			double result = Parser.calculatePostfixTokens(tokens);

			//Round to the second decimal place
			BigDecimal bigDecimal = new BigDecimal(result);
			bigDecimal = bigDecimal.setScale(decimalPlaces, BigDecimal.ROUND_HALF_UP);
			result = bigDecimal.doubleValue();

			//System.out.println("Result: "+result);

			return result+"";
		} catch( Exception e) {

			String errorMessage = e.getMessage();
			if(errorMessage!=null) {
				return errorMessage;
			}
			return "Calculator Error: \""+e.getClass().getName()+"\"";
		}
	}