I am having trouble with StringTokenizer. I have an input file that has an infix expressions followed by
a set of numbers which are the values for the variables
A + B * C
1 3 5 2 2 2
The goal is to take the infix and convert it to postfix. Then you will take the postfix and using the numbers evaluate the postfix expression. I have most of the methods completed to do the conversions and evaluations. My problem is getting the data out of the files.
I need to read the infix, print to an output file the infix, the postfix conversion, the values for the variables and the evaluated expression value.
I have my stacks, & queues set up. I just need help getting the data from the file.
StringTokenizer gives me tokens in strings but, I need to get characters and ints.
This is only a snippet of my full code but, it compiles but will not run.
Can anyone help with my use of StringTokenizer?
while(inFile.hasNext()) { line = inFile.nextLine(); st = new StringTokenizer(line); while(st.hasMoreTokens()) { test = st.nextToken(); //ops = st.nextToken.charAt(0); numbers = Integer.parseInt((st.nextToken())); } }