Java Reference
In-Depth Information
x = 5;
y = 80;
b.
do
x = x * 2;
while (x < y);
System.out.println(x + " " + y);
x = 5;
y = 20;
c.
do
x = x + 2;
while (x >= y);
System.out.println(x + " " + y);
5
x = 5;
y = 35;
d.
while (x < y)
x = x + 10;
System.out.println(x + " " + y);
x = 5;
y = 30;
e.
while (x <= y)
x = x * 2;
System.out.println(x + " " + y);
x = 5;
y = 30;
f.
while (x > y)
x = x + 2;
System.out.println(x + " " + y);
33. Write an input statement validation loop that prompts the user to enter a
number less than 20 or greater than 75.
34. Rewrite the following as a for loop:
int i = 0, value = 0;
while (i <= 20)
{
if (i % 2 == 0 && i <= 10)
value = value + i * i;
else if (i % 2 == 0 && i > 10)
value = value + i;
else
value = value - i;
i = i + 1;
}
System.out.println("value = " + value);
What is the output of this loop?
Search WWH ::




Custom Search