package lists; public class Calculator { public static List tokenize(String s) { List tokens = new List(); String number = ""; for (int i = 0; i < s.length(); i++) { char cc = s.charAt(i); if (Token.isDigit(cc)) number += cc; else if (Token.isOperator(cc)) { tokens.add(new Token(number)); tokens.add(new Token(cc)); number = ""; } } tokens.add(new Token(number)); return tokens; } public static List toPostfix(List l) { List postfix = new List(); return postfix; } public static double evaluate(List postfix) { return 0.0; } private static void printList(List l) { l.first(); while (!l.isLast()) { Token t = (Token)l.get(); System.out.println("token = " + t); l.next(); } Token t = (Token)l.get(); System.out.println("token = " + t); } public static void main(String args[]) { String input = "10 +304*14-99+88*7"; List tokens = tokenize(input); printList(tokens); List postfix = toPostfix(tokens); printList(postfix); double answer = evaluate(postfix); System.out.println(input + " = " + answer); } }