Java Assignment - hyrtutorials
1. Print 1 to 100 values
2. Print even numbers between 200 and 500
3. Print the numbers which are divisible by 7 for the range of 150 to 200
Java Code:
public class Assignment {
public static void main(String[] args) {
// 1. Print 1 to 100 values
[Link]("Numbers from 1 to 100:");
for (int i = 1; i <= 100; i++) {
[Link](i + " ");
}
[Link]("\n");
// 2. Print even numbers between 200 and 500
[Link]("Even numbers between 200 and 500:");
for (int i = 200; i <= 500; i++) {
if (i % 2 == 0) {
[Link](i + " ");
}
}
[Link]("\n");
// 3. Print numbers divisible by 7 between 150 and 200
[Link]("Numbers divisible by 7 between 150 and 200:");
for (int i = 150; i <= 200; i++) {
if (i % 7 == 0) {
[Link](i + " ");
}
}
}
}