April 27, 2003
Exercise 1A.1 Use the function computeInt to
determine the
result of the following expressions:
27 % 4,
-27 % 4,
27 % -4,
-27 % -4,
27.5 % 4.
Exercise 1A.2 Use the function
computeInt to
determine the result of the following expressions:
150 / 3 * 10
150 / (3 * 10)
10 / 3 * 10.
Exercise 1A.3 Use the function computeInt to
determine the result of the following expressions:
150 - 20 - 30 - 10
150 - (20 - 30) - 10)
(150 - 20) - (30 - 10).
Exercise 1A.4 Use the function computeInt to
determine the result of the following expressions. Experiment with
the second
expression to find out what is the largest integer Java can represent.
4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4
16 * 16 * 16 * 16 * 16 * 16 * 16 * 16 * 16 * 16.
Exercise 1A.5 Use the function computeInt to
determine the result of the following expressions. Experiment with
the second expression to find out what is the largest magnitude of
a negative integer that Java can represent.
-4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4 * 4
-16 * 16 * 16 * 16 * 16 * 16 * 16 * 16 * 16 * 16.
Exercise 1A.6 Use the function computeDouble to
determine the result of the following expressions:
27.6 % 4
-27.6 % 4
27.6 % -4
-27.6 % -4.
Exercise 1A.7 Use the function
computeDouble to
determine the result of the following expressions:
10 / 3 * 3.0)
10 / 3.0 * 3
10.0 / 3 * 3
10.0/3/3/3/3/3 *3*3*3*3*3
10.0/3/3/3/3/3/3/3/3/3/3 *3*3*3*3*3*3*3*3*3*3
10.0 *3*3*3*3*3*3*3*3*3*3 /3/3/3/3/3/3/3/3/3/3
1E20 /3/3/3/3/3/3/3/3/3/3 *3*3*3*3*3*3*3*3*3*3
1E20 *3*3*3*3*3*3*3*3*3*3 /3/3/3/3/3/3/3/3/3/3.
Exercise 1A.8 Use the function computeDouble to
determine the result of the following expressions:
1.0 / 0
-1.0 / 0
0.0 / 0
1 / 0.
Exercise 1A.9 Find out whether the function areaOfDisk allows the input to be an integer.
Exercise 1A.10 Find out what happens if you use int return type in the function areaOfDisk instead of double.