1. Represent each of the following infix expressions as a postfix expression:
1. (a+ b)/ (c- d)
2. a/(b-c)*d
3. a-(b/(c-d)*e+f)^g
4. (a-b*c)/(d*e^f*g+h)
2. Implement all the methods of the StackInterface (discussed in lesson) in class Stack. Create a demo class to test all methods using string as a datatype.
public interface StackInterface< T> {
/**
* Adds a new entry to the top of this tack.
*
* @param newEntry An object to be added to the stack.
*/
public void push(T newEntry);
/**
* Removes and returns this stack's top entry.
*
* @return The object at the top of the stack.
* @throws EmptyStackException if the stack is empty before the operation.
*/
public T pop();
/**
* Retrieves the stack's top entry.
*
* @return The object at the top of the stack.
* @throws EmptyStackException if the stack is empty.
*/
public T peek();
/**
* Detects whether this stack is empty.
*
* @return True if the stack is empty.
*/
public boolean isEmpty();
/**
* Removes all entries from this stack.
*/
public void clear();
}