by 
[Help |
API Docs |
Short Course|
Exercises]
For this exercise you will use a loop to print out some strings and use a nested loop to simulate a multiplication (6*3).
[If you are using IBM's VisualAge for Java for this exercise,
then use the scrapbook to type and test your code (without a
main method etc...), thus, avoiding the need to fill in the
skeleton code, compile, and run from the command line.].
Prerequisites
Skeleton Code
Tasks
Make a for loop that prints "Hello" 5 times.
Define an integer sum, initializing it to 0.
Make a loop that counts from 1 to 6.
Make an inner loop, nested within the previous loop,
that counts from 1 to 3. The statement of the inner loop should increment sum.
Print out the value of sum.
Where help exists, the task numbers above are linked to the step-by-step help page.
Solution Source
Demonstration
If you execute Forloop from a command line, the output should be similar to the following:
Hello
Hello
Hello
Hello
Hello
sum is 18
|
Copyright 1996-2000 jGuru.com. All Rights Reserved.
|
|