write a java program to evaluate postfix expressions containing complex numbers

QUESTION

“write a java program to evaluate postfix expressions containing complex numbers using a stack. This program should contain two classes. The first class Project2 should contain the two methods described below:The main method, which performs the expression evaluation. 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 stackevaluatepush result onto the stackpop the final result off the stackThe user should be allowed to enter and evaluate any number of expressions.A class method called evaluate, which accepts two complex numbers and a operator and returns the result of performing the operation on those two numbers.The second class should be a class named Complex. Each complex number should contain a real and imaginary part. Each should be of type double. This class should contain the following methods.A constructor.A class method named fromString that accepts a StringTokenizer positioned at a complex number and returns that complex number.A toString method that converts a complex number to a string.A add method that adds two complex numbers and returns the result.A subtract method that subtracts two complex numbers and returns the result.A multiply method that multiplies two complex numbers and returns the result.Each 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. ”

 

ANSWER:

REQUEST HELP FROM A TUTOR

Expert paper writers are just a few clicks away

Place an order in 3 easy steps. Takes less than 5 mins.

Calculate the price of your order

You will get a personal manager and a discount.
We'll send you the first draft for approval by at
Total price:
$0.00