Type in your answers to each of these questions in a file named
prelab08.txt
in your Prelab Questions
directory. Turn in your answers before the
beginning of your laboratory session.
Question #1: Which of the Java loops is a pretest loop?
Question #2: Which of the Java loops is a posttest loop?
Question #3: Which of the Java loops can provide both zero and one-trip behavior?
Question #4: Which of the Java loops is designed primarily for counting through ranges of numbers?
Question #5: An
if
-break
combination must be
used if one wishes to exit from which Java loop?
Write just the loop controls for these questions; don't worry what goes in the body.
Code #1: Write a for
loop that
counts from 1 to 100 (inclusive).
Code #2: Write a while
loop that
continues to loop when x
is between 1 and 100
(inclusive).
Code #3: Write a do
loop that
continues to loop when x
is between 1 and 100
(inclusive).
Code #4: In terms of execution, what is the
difference between the while
and do
loops
for the previous two questions?
Code #5: Write a forever loop that
continues when x
is between 1 and 100
(inclusive).