(Review: ) Is the following a correct expression?

13 * 6 -

Answer:

No.

Expressions

The literals (the integers) and the operators are out of order in the above incorrect expression. (One legal arrangement is     13 * -6    for 13 times minus 6.)

An expression is a combination of literals, operators, variable names, and parentheses used to calculate a value.

The parts of an expression must be arranged correctly. The syntax of Java describes the correct arrangements. The details of this will be left to another course (or your Java documentation, if you care to dig through it.) The rules for correct Java expressions are about the same as for algebra.

We need to talk about operators and operands. You already know what an operator is (a symbol such as +, -, *, or / that calls for an arithmetic operation).

An operand is a value that is acted upon by an operator.

For example, in 13 - 5 the 13 and the 5 are the operands and the - is the operator. Examine the following expressions. Assume that each variable has already been correctly declared. Decide if the expression is correct, then click on the button.

Expression Correct or Not Correct?Expression Corrector Not Correct?
25 25 - value
2( a - b ) (a-b) * (c-d)
A - b/c + D -sum + partial
( (x+y) / z ) / ( a - b ) ( (m - n) + (w-x-z) / (p % q )

 

QUESTION 2:

Are arithmetic expressions the only kind of expression?