Encerrado

java

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 escapedThe 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. .

## Deliverables

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.

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 Roy LevowObserve 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. The assignmentCode a Java application program using a class named Expr to operate on expressions as described above. Grading considerationsHandling precedence is worth 15 points of the total. Suggestion: Develop the program first without precedence, evaluating operations strictly from left to right and then add precedence handling. A program that does not run at all will get at most 50 points. A program that does not compile will get a zero.

Design hintThe 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.

Error handlingThe program must run correctly on correct data. Behavior of the program on erroneous data is not defined and no special error handling is required

## Platform

Windows XP.

Java and Unix.

Habilidades: Engenharia, Java, Linux, Microsoft, MySQL, PHP, Arquitetura de software, Teste de Software, UNIX, Área de trabalho do Windows

Ver mais: using stack java example, using expressions, use data structures, used structures, strings standard, stack data structures, software stacks, simple algorithm example, push algorithm, program algorithm example, operations data structures, line algorithm, java data structures examples, java command line application, examples data structures, examples algorithm, design argument, data structures using, data structures operations, data structures examples java, data structures examples, data structures example, data structures code, data structures arrays, data structures array

Acerca do Empregador:
( 2 comentários ) United States

ID do Projeto: #2976538

20 freelancers estão ofertando em média $20 para este trabalho

mihaiscortaru

See private message.

$25.49 USD in 2 dias
(160 Comentários)
6.0
emilianbold

See private message.

$12.75 USD in 2 dias
(80 Comentários)
5.9
leepwo

See private message.

$21.25 USD in 2 dias
(41 Comentários)
4.7
herculesevw

See private message.

$18.7 USD in 2 dias
(79 Comentários)
4.7
stojoman

See private message.

$17 USD in 2 dias
(44 Comentários)
4.6
vw821235vw

See private message.

$17 USD in 2 dias
(94 Comentários)
4.3
seirus

See private message.

$16.15 USD in 2 dias
(36 Comentários)
4.0
always99vw

See private message.

$21.25 USD in 2 dias
(22 Comentários)
3.4
patrica

See private message.

$14.45 USD in 2 dias
(19 Comentários)
3.2
vasilpanayotov

See private message.

$18.7 USD in 2 dias
(8 Comentários)
3.2
sixi

See private message.

$25.49 USD in 2 dias
(11 Comentários)
2.7
uytvbn

See private message.

$11.05 USD in 2 dias
(3 Comentários)
2.5
ciphereye

See private message.

$11.05 USD in 2 dias
(16 Comentários)
2.7
vw653941vw

See private message.

$21.25 USD in 2 dias
(11 Comentários)
2.4
seanmcox

See private message.

$17 USD in 2 dias
(2 Comentários)
1.6
voldemortvw

See private message.

$21.25 USD in 2 dias
(0 Comentários)
0.0
w31rd0

See private message.

$25.5 USD in 2 dias
(0 Comentários)
0.0
angelusnoctis

See private message.

$25.5 USD in 2 dias
(0 Comentários)
0.0
darlk

See private message.

$25.5 USD in 2 dias
(1 Comentário)
0.0
codefm

See private message.

$25.5 USD in 2 dias
(0 Comentários)
0.0