Computer Science, asked by rumadasmondal41, 9 months ago

Write a Java program that will accept three unequal integer number and display the difference between the largest and the smallest number

Answers

Answered by Anonymous
1

Answer:

Hi ! I am Professional programmer. Mark as BRAINLEST

Explanation:

import java.util.Arrays;

import java.util.Scanner;

public class Main {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

int n = sc.nextInt();

int a[] = new int[n];

for (int i = 0; i < n; i++) {

a[i] = sc.nextInt();

}

int n1 = display(a);

System.out.println(n1);

}

public static int display(int[] array)

{

Arrays.sort(array);

int n = array[array.length - 1] - array[0];

int b = array.length;

if (b == 1) {

n = array[0];

}

return n;

}

}

Similar questions