Question 1: Compute the value of each of the following Java expressions and specify the type.  Give the values Java would compute.

                                          Type                      Value

 

(a)    8.2 – 13 / 3 * 2.5         __double___              __-1.8___

(b)   7 * 3 / 8                       ___int_____              ____2____

(c)    30 / (8 *  1.5)               __double___              ___2.5___

(d)   11 - 10 / 4 + 2             _____int___              ____11___

(e)    6 / 5 * 3.5 - 2                ____double____             __1.5____

(f)     30 / 8 *  1.5               _double____              __4.5____

(g)    2 % 2 + 2 * 2               ___int_____              ____4____

(h)    7.5 + 3 * 6 / 4              __double___              _11.5____

(i)      (3 * 3 * (3 + (9 / 4)))   ____int____              __45_____

(j)     4 * 5 + 13 / 10.0          _double____              _21.3____

 

Question 2: Write the Java statements for the following descriptions.

 

(a)    Declare a variable called count of type int.

________int count;______

(b)   Declare a variable called distance of type double.

____________double distance;____________________________________________

(c)    Declare a variable called found of type boolean.

___________boolean found;_________________________________________

(d)   Declare a variable called middle of type char.

__char middle;_____

(e)    Declare quot1, a variable of type double, and set it equal to the equation:.  (You may assume the variables k, A, x, y, r, and z have already been declared as doubles.)

_________double quot1 = Math.pow(A,2)*(r + z) * k / (Math.pow(x+y, 2));___

(f)    Declare quot3, a variable of type double, and set it equal to the equation:.  (You may assume the variables k, A, x, y, r, and z have already been declared as doubles.)

___double quot3 = Math.pow(A, 2) * (r+z) / (k * (x+y));_____

(g)    Declare quot4, a variable of type double, and set it equal to the equation:.  (You may assume the variables k, A, x, y, r, and z have already been declared as doubles.)

____double quot4 = (r + Math.pow(z, 2)) / (A * k * (x-y));_______

(h)      Declare quot5, a variable of type double, and set it equal to the equation:.  (You may assume the variables k, A, x, y, r, and z have already been declared as doubles.)

___double quot5 = Math.pow(k * r - z, 2)/ Math.pow(x + y * A, 2)___

(i)     Declare quot6, a variable of type double, and set it equal to the equation:.  (You may assume the variables k, A, x, y, r, and z have already been declared as doubles.)

___double qout6 = r * z / ((x*x + y*y) * (A + k));____