Code a Java application program using a class named Expr to operate on expressions as described**. The Unix command expr treats its command line argument as an expression to be evaluated and prints the resulting value. The Unix man page includes the following description. The expr utility will evaluate the expression and write the result to standard output. Arguments are taken as an expression. Terms of the expression must be separated by blanks. Characters special to the shell must be escaped The Unix command supports a variety of operators with several precedence levels. Your application will support only the operators +, -, x, and d. 'x' is used in place of '*' for multiplication and 'd' in place of '/'for division to avoid conflicts with command interpreter special usage. Standard associativity and precedence apply. Operands must be integer constants and may optionally have a minus sign. In addition, if the program is run with no parameters, it is to print the message shown in the example below, but with your name rather than mine. Here are some simple examples. $java Expr 1 + 2 3 $java Expr 1 + 2 x 3 7 $java Expr 1 + 6 d 3 x 2 5 $java Expr Java Expr programmed by (name) Observe that the Java interpreter takes the values following the class name and places them in an array of strings that is passed as the argument value for main. You just use those values, you do not have to read anything within your program.
1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done. 2) Installation package that will install the software (in ready-to-run condition) on the platform(s) specified in this bid request. 3) Complete ownership and distribution copyrights to all work purchased. 4) [url removed, login to view] source file 5) Output showing thorough testing of the program from the command line so that both the command and the corresponding output are shown 6) The [url removed, login to view] file Make sure the permissions on the directories and the file are correctly set as described Design hint The following algorithm is commonly given as an example of the use of a stack in data structures texts, though with more complex expressions. A simple way to handle precedence is to use two stacks, one for the operators and one for the operands. Start by pushing some distinctive symbol onto the operator stack to mark the beginning of the expression. This symbol is considered to have very low precedence. Then push the first operand onto the operand stack. Then repeat the following process. 1. If the next operator in the input has precedence less than or equal to the one on the top of the operator stack, apply the operator on the top of the stack to the two operands on top of the operand stack and push the result back onto the operand stack. Pop the operator off the stack and repeat this step. 2. If the next operator has higher precedence than the one on top of the operator stack, push it onto the operator stack and push the next operand onto the operand stack. 3. When input is complete, repeatedly apply the evaluation process of step 1 until only the beginning-of-expression operand is left on the operator stack. The value on the operand stack is the result. You can use arrays to implement the stacks or you can use the Java Stack class. You can assume that there are no more than 50 operators and 50 operands in an expression.
WINDOWS and LINUX