7.2.. Napisati program za odredjivanje y po formuli:

Listing programa:

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

    System.out.println("x: ");
    System.out.println ("Odredjivanje y po formuli");
    System.out.print("x: ");
    double x = input.nextInt();
    double y;
    if (x <= -2)
    	y = x + 2;
    else
    	if ((-2 > x) || (x < 2))
    	  y = 2;
    	else 
    	  y = x - 2;
    System.out.println("y = " + y);
}}	

Ispis na ekranu:

Index