The document outlines a Java assignment that includes three tasks: printing numbers from 1 to 100, printing even numbers between 200 and 500, and printing numbers divisible by 7 in the range of 150 to 200. It provides the Java code necessary to accomplish these tasks. The code uses loops and conditional statements to achieve the desired outputs.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
0 views1 page
Java Assignment Hyrtutorials
The document outlines a Java assignment that includes three tasks: printing numbers from 1 to 100, printing even numbers between 200 and 500, and printing numbers divisible by 7 in the range of 150 to 200. It provides the Java code necessary to accomplish these tasks. The code uses loops and conditional statements to achieve the desired outputs.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1
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
System.out.println("Numbers from 1 to 100:"); for (int i = 1; i <= 100; i++) { System.out.print(i + " "); } System.out.println("\n");
// 2. Print even numbers between 200 and 500
System.out.println("Even numbers between 200 and 500:"); for (int i = 200; i <= 500; i++) { if (i % 2 == 0) { System.out.print(i + " "); } } System.out.println("\n");
// 3. Print numbers divisible by 7 between 150 and 200
System.out.println("Numbers divisible by 7 between 150 and 200:"); for (int i = 150; i <= 200; i++) { if (i % 7 == 0) { System.out.print(i + " "); } } } }