Professional Documents
Culture Documents
1: Loop Structures
Activity 1.
1. Write a program that prints all even numbers from 1 to 50 inclusive using the for loop,
while loop, and do…while loop. The class name is EvenNum. (20PTS)
Expected output:
Your Output:
Activity 1.2. Write a program that sums the integers from 1 to 50 using any looping
statement. The class name is Sum50. (20PTS)
Expected output:
Your Output:
Activity 1.3. Write a program that prints every integer value from 1 to 20 along with its
squared value using the following looping structures (for, while, and do-while loop). The
class name is TableOfSquares. (30PTS)
Expected output:
Your Sourcecode:
Your Output:
Activity 1.5. Write a for statement to compute the sum of an N as an entered integer 1 +
2² + 3² + 4² + 5² + ... + N². (50PTS)
Expected Output:
Your Output: