Instructions: Answer as many of the following questions as you can during the lab period. If you are unable to complete the assignment during the lab period it is strongly recommended that you complete it on your own.
TIMES
|
Multiplication |
DIVIDED_BY
|
Division |
DIVIDED_BY_WITHOUT_REMAINDER
|
Integer Division |
REMAINDER_AFTER_DIVISION
|
Remainder |
PLUS
|
Addition |
MINUS
|
Subtraction |
ASSIGNED
|
Assignment |
what is the value of x
after each of the following statements
is evaluated:
x ASSIGNED 5
x ASSIGNED 5 PLUS 2
x ASSIGNED 5 DIVIDED_BY 2
x ASSIGNED 5 DIVIDED_BY_WITHOUT_REMAINDER 2
x ASSIGNED 5 REMAINDER_AFTER_DIVISION 2
x ASSIGNED 5 MINUS 2 TIMES 2
*
|
Multiplication |
/
|
Division |
DIV
|
Integer Division |
MOD
|
Remainder |
+
|
Addition |
-
|
Subtraction |
<-
|
Assignment |
what is the value of x
after each of the following statements
is evaluated:
x <- 16
x <- 16 + 4
x <- 16 / 4
x <- 16 DIV 4
x <- 16 MOD 4
x <- 16 - 4 * 4
+
|
Positive |
-
|
Negative |
++
|
Increment (i.e., increase the operand by 1) |
--
|
Decrement (i.e., decrease the operand by 1) |
and the following binary operators (also in decreasing order of precedence, all of which are of lower precedence than the unary operators):
*
|
Multiplication |
/
|
Division (integer or real depending on operands) |
%
|
Remainder |
+
|
Addition |
-
|
Subtraction |
=
|
Assignment |
what is the value of x
after each of the following statements
is evaluated:
x = 5 - 2 * 2
x = 3 + 8 * 3 - 5 * 2
x = 3 + 8 * 3 - 5 % 2
x = - 16 + 4 * 2
x = 16 % ++ 4
x = 16 % 4 + 1
7 / 3
7 / 2
7. / 2.
7. / 2
7 / 2.
int
variable today
denote the
integer corresponding to today and letting the int
variable days
denote the number of days in the future
we are interested in, and the int
constant
DAYS_PER_WEEK
denote the numer of days in a week,
genealize your answer to the previous question
so that it will work for any day of the week and number of days.
5792
. (Note: You must not use subtraction
and your answer must use the number 5792.) (Example of Use: Suppose
you are given a four digit number. You might want to determine the
century.)
978
. (Note: You must not use subtraction
and your answer must use the number 978.)
int
variables
named pounds
,
ounces
, and changeInOunces
that contain
your current weight in pounds and ounces and your change of weight
in ounces, write two Java statements that can be used to calculate
your weight in pounds and ounces after the change.
*
|
Multiplication |
/
|
Division (integer or real depending on operands) |
%
|
Remainder |
+
|
Addition |
-
|
Subtraction |
=
|
Assignment |
evaluate each of the following expressions written using postfix notation (assuming left-to-right associativity):
5 2 - 2 *
3 8 + 3 * 5 - 2 *
3 8 + 3 * 5 - 2 %
Copyright 2013