COSC 311 Homework 1/23/2017 Evaluate postfix expression using a stack Distributed: 1/23/2017 Due: 1/30/2017 (one week!) Write Java code using a singly linked list implementation of a stack (see page 233, Code Fragment 6.4) to evaluate a postfix expression comprising only floating point numbers and binary operators +, -, *, /. The pseudo-code to evaluate a postfix expression is: double evalPostFix(input) { // input is postfix expression (no errors) // S is initially empty stack while (more input) { token = read(); if (token is operand) S.push(token); // A else if ( token is operator ) { S.pop() the required number of operands; result = evaluate using operands and token; S.push(result); } } // -A return ( S.peek() ); } I expand the section between // A and // -A for those who are not sure how to go about actually *evaluating* // A else if (token == "+") { op1 = S.pop(); op2 = S.pop(); result = op1 + op2; S.push( result ); } else if (token == "-") { op1 = S.pop(); op2 = S.pop(); result = op1 - op2; S.push( result ); } else if // similar for "*" and for "/" ... // -A C-6.19, page 253 gives the definition of a postfix expression defined in terms of an infix expression. Data Structure: Stack implemented as singly-linked list. The Nodes in the linked-list may Use template (as given in the book), or they may be restricted to String (or Object) for the data type. Constraints: -- You must use or cannabilize the code given on page 233. -- Do not use any built-in Java classes beyond primitive types, System, Arrays String, Scanner, Pattern, and Matcher. -- Node class and Stack class can be in the same file or in separate files. -- The output must be clearly labeled with the input string. -- You may assume no errors in the input. Output for runs on the data (output does not need to be aligned as shown). You need to give the input string with the value. Trailing zeros are not an issue. " 3.0 2.0 4.0 + * " -> 18.0 " 3.0 2.0 4.0 + 5.0 + * " -> 33.0 " 3.0 2.0 4.0 5.0 + * + " -> 21.0 You can do one run or three runs to get the value of the three expressions shown. Turn in: Hardcopy of your code. In your code, include a header: [your name] [your URL] COSC 311 HW 01/23 WINTER 2017