I Write a program with a loop that iterates as long as an int variable called num is less or equal to 50. Num must be initialized with a value of 1 and incremented by 1 with each iteration. Each iteration of the loop must print all appropriate sentences for that number according to the following 1. If num is odd, output: num is an odd number 2. If num is even, output: num is an even number output: num is divisible by 2 3. If num is divisible by 2, 4. If num is divisible by 5, output: num is divisible by 5 5. If num is divisible by 8, output: num is divisible by 8 6. If num is divisible by 11, output: num is divisible by 11 Please note that your class should be named FirstLoop.
Homework 5
CMP 167:
Homework 5-1
I
Write a program with a loop that iterates as long as an int variable called num is less or equal to 50.
Num must be initialized with a value of 1 and incremented by 1 with each iteration.
Each iteration of the loop must print all appropriate sentences for that number according to the following
1. If num is odd,
output: num is an odd number
2. If num is even,
output: num is an even number output: num is divisible by 2
3. If num is divisible by 2,
4. If num is divisible by 5,
output: num is divisible by 5
5. If num is divisible by 8,
output: num is divisible by 8
6. If num is divisible by 11,
output: num is divisible by 11
Please note that your class should be named FirstLoop.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps