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

Listing programa:

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

    System.out.println ("Odredjivanje z po formuli");
    System.out.print("Dva broja: ");
    double a = input.nextInt();
    double b = input.nextInt();
    double z;
    if (a > 0)
    	z = b / a;
    else
    	if ((-3 < a) || (a <= 0)) 
    		z = a + 3;
    	else 
    		z = 2 * b;
    System.out.println("z = " + z);
}}

Ispis na ekranu:

Index