7.2.. Napisati program za izračunavanje vrijednosti prema izrazu:

Listing programa:

package Zadatak;
import java.util.Scanner;
public class P07212509 {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		System.out.println("Unesi b");
		int y;
		int b = input.nextInt();
		if (b > 0)
			y = 1;
		else
			y = 3;
		System.out.println("y=" + y);
	}
}

Ispis na ekranu:

Index