7.2.. Napisati program za odredjivanje y po formuli:

Listing programa:

package zadatak;
import java.util.Scanner;
public class P07211040 {
	public static void main(String[] args)	{
	Scanner input = new Scanner (System.in);

	int a,y;
	System.out.println ("Paran");
	System.out.print ("Broj ");
	a = input.nextInt();
	if (a % 2 == 0)
		y = a + 3;
	else 
		y = a - 2;
	System.out.println ("Broj = " + a + " nova vrijednost = " + y);
	}
}

Ispis na ekranu:

Index