Due on Wednesday, March 17, 2004
Submission Method: Neat and legible hard copy.
1. Determine the number of loop iterations for each of the following: [6 marks]
for (int i = 0; i < 10; i++)
for (int i = 1; i < 10; i++)
for (int i = 0; i < 100; i +=2)
for (int i = 1; i < 50; i +=2)
for (int i = 1000; i > 10; i--)
for (int i = 5; i < 150; i +=5)
2. Write a loop to sum all the numbers from 3 to 47. [4 marks]
3. There is a hockey tournament involving 6 teams. Write a short program that will display all the games if each team plays the other twice. The output format should be:
Team 1 plays Team 2
Team 1 plays Team 3
Team 1 plays Team 4
Team 1 plays Team 5
Team 1 plays Team 6
Team 2 plays Team 1
Team 2 plays Team 3
Team 2 plays Team 4 ... and so on.
HINT: You will need to nest two for loops to solve this. WARNING: You can't say Team 3 plays Team 3. Print your code and hand it in as hard copy. All code can be in the main method. [10 marks]