private static String calculate(String input) throws Exception {
		if (input.equals("")) {
			return(input);
		}
		
		double val1, val2, result;
		String output = null;
		String symbol;
		Stack<Double> stack;
		String[] symbols;
		
		stack = new Stack<Double>();
		symbols = input.split(" ");
		
		for (int i = 0; i < symbols.length; i++) {
			symbol = symbols[i];
			if (symbol.equals("")) {
				continue;
			}
			if (symbol.equals("+")) {
				val1 = stack.pop();
				val2 = stack.pop();
				result = val1 + val2;
				stack.push(result);
			} else if (symbol.equals("*")) {
				val1 = stack.pop();
				val2 = stack.pop();
				result = val1 * val2;
				stack.push(result);
			} else if (symbol.equals("-")) {
				val1 = stack.pop();
				val2 = stack.pop();
				result = val2 - val1;
				stack.push(result);
			} else if (symbol.equals("/")) {
				val1 = stack.pop();
				val2 = stack.pop();
				result = val2 / val1;
				stack.push(result);
			} else if (symbol.equals("=")) {
				output = fmt(stack.pop());
				if (!stack.empty()) {
					throw new TooManyValuesException();
				}
			} else {
				val1 = Double.parseDouble(symbol);
				stack.push(val1);
			}
		}
		
		
		return output;
		
	}