WAP to store ten numbers in an array by user input and find the maximum and minimum numbers.

import java.util.*; class T13 { public static void main(String[] args) { int[] arr = new int[10]; int i, n; Scanner sc = new Scanner(System.in); System.out.println("Enter 10 digits to find the maximum and minimum: "); for (i = 0; i < 10; i++) { arr[i] = sc.nextInt(); } System.out.println("Here are the numbers entered by you: "); for (i = 0; i < 10; i++) { System.out.println(arr[i] + " "); } Arrays.sort(arr); System.out.println("Here are the sorted numbers entered by you: "); for (i = 0; i < 10; i++) { System.out.println(arr[i]); } System.out.println(arr[0] + " is the minimum number."); System.out.println(arr[9] + " is the maximum number."); } } Copy Code
Expected Output:
Input:
Enter 10 digits: 34 12 87 56 23 78 45 89 24 67

Output:
12 is the minimum number.
89 is the maximum number.