Boost your Grades with us today!

History homework help

write a java program to evaluate postfix expressions containing complex numbers using a stack. The algorithm for evaluating a postfix expression requires a stack of complex numbers. The pseudocode for evaluating postfix expressions is given below: while not end of expressionswitch next tokencase complex number:push the value onto the stackcase operator:pop two operands from the stackevaluate operationpush result onto the stackpop the final result off the stackEach complex number will all be enclosed in a pair of parentheses. The operators permitted include +, – and *. You may assume that all expressions are syntactically correct. The user should be allowed to enter and evaluate any number of expressions. Here is what I have done so far:import*;import java.util.Stack;import java.util.Scanner;public class stack {public static void main(String[] args) {Stack pstack = new Stack();Stack pstack2 = new Stack();Scanner input = new Scanner(;System.out.println(“Please enter a value: “);String result = input.nextLine();Integer.parseInt(result);pstack.push(result);//System.out.println(pstack);for (int i=0; i < result.length(); i++){char ch = result.charAt(i);//Checks the characters switch(ch) { case '+': int x,y;int op1 = ((Integer)(pstack.pop())).intValue();int op2 = ((Integer)(pstack.pop())).intValue();pstack.push(new Integer(op2 + op1));System.out.println(pstack);break; case '-': int op1 = ((Integer)(pstack.pop())).intValue();int op2 = ((Integer)(pstack.pop())).intValue();pstack.push(new Integer(op2 - op1));break; case '*': int op1 = ((Integer)(pstack.pop())).intValue();int op2 = ((Integer)(pstack.pop())).intValue();pstack.push(new Integer(op2 * op1));System.out.println(pstack);break; case '/': int op1 = ((Integer)(pstack.pop())).intValue();int op2 = ((Integer)(pstack.pop())).intValue();pstack.push(new Integer(op2 / op1));System.out.println(pstack);break; }//System.out.println(pstack);}}}


15% off for this assignment.

Our Prices Start at $11.99. As Our First Client, Use Coupon Code GET15 to claim 15% Discount This Month!!

Why US?

100% Confidentiality

Information about customers is confidential and never disclosed to third parties.

Timely Delivery

No missed deadlines – 97% of assignments are completed in time.

Original Writing

We complete all papers from scratch. You can get a plagiarism report.

Money Back

If you are convinced that our writer has not followed your requirements, feel free to ask for a refund.

Need Help? Please contact us