147
c. g. –
d. + y
4.Given the declarations
int i;
long n;
doublex;
doubley;
write a valid Java expression for each of the following algebraic expressions. Use
calls to math methods wherever they are useful.
a.|i| e.
b.|n| f. x^6 + y^5
c. |x+ y| g. (x+ y)^7
d.|x|+ |y|
5.Write expressions to compute both solutions for the quadratic formula. The for-
mula is
The symbol means “plus or minus” and indicates that the equation has two
solutions: one in which the result of the square root is added to band one in
which the result is subtracted from b. Assume all variables are floatvariables.
6.Enter the following application into your computer and run it. In the initial com-
ments, replace the items within parentheses with your own information. (Omit
the parentheses.)
//
// Programming Assignment One
// (your name)
// (date application was run)
// (description of the problem)
//
–bb^2 – 4ac
2 a
x^3
x+ y
^1
x
x– y
5
x+ y
3
^1
x+ y
4 x