3. The following formula enables us to compute the area a of a right triangle with sides x and y:
1
a = - xy
2
Assuming that x and y are already placed in the corresponding variables of type double, write a
Java code statement for assigning the corresponding value to the variable a of type double. Explain,
step-by-step, which arithmetic operations will be performed first, which next, etc., and
trace the computations on the above example.
Describe two different ways to avoid getting 0 as the result of evaluating 1/2.
Explain what happens if you simply write xy in
your Java code.
6. Suppose that would like to add 2 to the number of years. If the number of years is stored in the integer variable years, which of the two lines of code leads to a correct increase: