Starting from:

$20

CSC20- Lab 6 Programming Concepts and Methodology II Solved

Objective: 

The objective of this lab is to get you some experience in processing strings character by character and in implementing stacks and queues in a class package.

The programming assignment:

In your lab05, replace instructor’s Tokenizer class and MyStackQueue package with your own.

Requirements:

You must use a linked list to implement your queue.
You must use an array to implement your stack.
You must use the following frame work to implement your tokenizer.
class Tokenizer { private char [] Buf;

private int cur;

Tokenizer(String infixExpression) { Buf = infixExpression.toCharArray(); cur = 0;

}

boolean moreTokens() {

                            Skip blanks.

                            return cur<Buf.length;

}

Token nextToken() { 1. Skip blanks.

if (cur>=Buf.length) return null;
If the next character is a digit, keep reading until a non-digit is read. Convert the string of digits into an integer.
String Digits = new String(Buf, start, len);

int num = Integer.valueOf(Digits).intValue();

     Use num to create and return an operand.

Otherwise, use the next character to create and return an operator.
}

}

More products