7.2.. Napisati program za odredjivanje y po formuli:

Listing programa:

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

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

Ispis na ekranu:

Index