Type in your answers to each of these questions in a file named
prelab05.txt
in your Prelab Questions
directory. Turn in your answers before the
beginning of your laboratory session.
Question #1: What change is made to OCD to deal with methods? (This is a review.)
Question #2: Selective execution can be performed using what Java statement?
Question #3: What Java statement allows you to execute a statement repeatedly, while counting?
Question #4: Why type of data must be
used in a conditional expression in an if
or loop
statement?
Question #5: What library do the selection and repetition statements come from? (This is a bit of a trick question.)
For all of these questions, assume that value
is
declared as an int
variable, and that
theScreen
has been declared as it's always
declared.
Code #1: Write a simple if
statement that prints a message to theScreen
if
value
is less than zero.
Code #2: Write a basic if
statement that prints a message to theScreen
if
value
is between 0 and 100 (inclusive) and that prints
a different message if value
is not in this
range.
Code #3: Write a counting for
loop
that prints "Hi there"
on the theScreen
500 times.