8.1. Ispis paranih i neparnih brojeva od 1 do n (test parnosti i neparnosti).

Listing programa:

package for_petlja;
import java.util.Scanner;

public class P08111008 {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);

		System.out.print("Unesi n: ");
		int n=input.nextInt();
		
		for(int i=1; i<=n; i++){
			if (i%2==0)
				System.out.println(i +"-paran");
			if (i%2!=0)
				System.out.println(i +"-neparan");
			}
	}
}
II Varijanta
		for(int i=1; i<=n; i++){
			if (i%2==0)
				System.out.println(i +"-paran");
			else
				System.out.println(i +"-neparan");
			}

Ispis na ekranu:

Index