
Csci 1301, Lab 4
2008.06.18
LoopLab.java
1
Lab 4 will initially look very much like the loops weāve written in class. Weāll
spice it up by nesting some conditionals inside of the later loops.
Part 2 will involve a simple print statement. Part 3 will require you to use an if
statement (or some clever coding). Parts 3 and 4 will get you started using expressions
inside a loop.
1. Input two int values from the user. These will serve as upper and lower bounds
for a loop.
2. Use a while loop to print out all values greater than or equal to the lower
bound but less than the upper bound. Use the print statement and the ā\tā
character to avoid printing each number on its own line.
3. Use a for loop to do almost the same thing. Except only print out the even
values. Hint: All even values have a remainder of 0 when divided by 2.
4. Use a loop of your choice to print out the squares of all of the perfect squares of
numbers between 1 and 100. (E.g. 1, 4, 9, ā¦, 10000) Remember, donāt āhard-
codeā in any values here. Create constants (āfinal variablesā) instead. Also, just to
make it tricky, print out ten values, tab-separated, on each line.