7.2.. Za učitane a i b izračunati z prema formuli:

Opis rješenja:

Listing programa:

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

		System.out.print("Unesi a: ");
		double a=input.nextDouble();
		System.out.print("Unesi b: ");
		double b=input.nextDouble();
		double max,max2;
		max=a;
		max2=(Math.pow(a, 2));
		
		if(b>max) 
		  max=b;
		if ((b*b)>max2) 
		   max2=(b*b);
		
		if(b>=0) 
		   System.out.print(2-max);
		else 
		   System.out.print(max2);
	}
}

Ispis na ekranu:

Index