1) static final int EndVal = -1; int double; int num = console.nextInt(); while
ID: 3638198 • Letter: 1
Question
1)static final int EndVal = -1;
int double;
int num = console.nextInt();
while (num != EndVal)
{
double = num * 2;
System.out.println(double);
num = console.nextInt();
}
The above code is an example of a(n) ____ while loop.
a) flag-controlled
b) counter-controlled
c) EOF-controlled
d) sentinel-controlled
2)
boolean found = false;
int num;
int square;
while (!found)
{
num = console.nextInt();
square = num * num;
if (square > 40)
found = true;
}
The above code is an example of a(n) ____ loop.
a) flag-controlled
b) counter-controlled
c) EOF-controlled
d) sentinel-controlled
Explanation / Answer
please rate - thanks
1)
static final int EndVal = -1;
int double;
int num = console.nextInt();
while (num != EndVal)
{
double = num * 2;
System.out.println(double);
num = console.nextInt();
}
The above code is an example of a(n) ____ while loop.
a) flag-controlled
b) counter-controlled
c) EOF-controlled
d) sentinel-controlled it is looking for a special value of num. this is the sentinel
2)
boolean found = false;
int num;
int square;
while (!found)
{
num = console.nextInt();
square = num * num;
if (square > 40)
found = true;
}
The above code is an example of a(n) ____ loop.
a) flag-controlled found is a flag that is set to indicate completion of the loop
b) counter-controlled
c) EOF-controlled
d) sentinel-controlled
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.