Exercise 2.7
-
- 6 / 4*2
- 2 * 3/2
- (int) 2.7*1. 8
- (int)2.7*(int)1.8
- (int)(2.7*1.8)
-
For each expression, determine its mathematical value and then run
a Java program that prints the value of the expression. Explain any
differences.
- 3.0*(1.0/3.0 + 100.0 - 100.0)
- (5E305 + 7E307)*10
- 18 + 1E18 - 1E18
- 1E18 - 1E18 + 18
- 1E-200 * 1E-200 * lE200 * lE200
- 1E200 * lE200 * lE-200 * lE-200
-
A quadratic equation of the form ax2 + bx + c = 0 has roots
Write a fragment that efficiently determines the values of the roots
(rootl and root2) of the quadratic equation with coefficients a, b,
and c. Assume that all the variables have been declared as type
double and that the equation has two real roots.
-
Rewrite the statement
m = n-- * ++p;
using three statements.
| |