6.4.. Učitati 4 cijela broja i izračunati aritmetičku sredinu koristeći samo varijable x, s i as.

Listing programa:

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

		System.out.print("Unesite brojeve: ");
		int x = input.nextInt();
		int s = input.nextInt();

		double as = x + s;

		x = input.nextInt();
		as = as + x;

		s = input.nextInt();
		as = (as + s) / 2;

		System.out.print("Aritmeticka sredina je: " + as);
	}
}

Ispis na ekranu:

Index