Try It Yourself: Arithmetic Expressions
- Assume you have been given:
int x = 8, y = 7, z = 1;
double a = 2.0, b = 3.5;
Evaluate the following expressions:
y * 2 + x / 3
(a + 3.0) * -b + 4.5
x % 5 + y * a
y / a + b - x / (-4 + y)
Math.sqrt(x * (y + z))
- What is the value of r after the following code executes:
int p = 3;
int q = p * 7;
p = 4;
int r = q / p;
- Assume you have been given:
final int QUAD = 4;
Write a Java code fragment to compute: