7.2.. Napisati program za odredjivanje y po formuli:

Listing programa:

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

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		System.out.println("Unesi x");
		double y;
		double x = input.nextDouble();
		if (x > 0)
			y = x + 3;
		else if (x < 0)
			y = x - 3;
		else
			y = 2;
		System.out.println("y=" + y);
	}
}

Ispis na ekranu:

Index