package hw3;
public class Main {
public static void main(String[] args) {
final int NumberOfElements = 1000;
int[] num = new int[NumberOfElements];
int var = 0;
//create input
java.util.Scanner input = new java.util.Scanner(System.in);
for (int i = 0; i < NumberOfElements; i++) {
System.out.print("Enter any positive number or enter 0 to stop: ");
num[i] = input.nextInt();
var++;
if (num[i] == 0)
break;
}
Arrays.sort( num, 0, var);
int i;
for (i = 0; i < var; i++) {
System.out.print(" " + num[i]);
}
}
}
Write a Java program reading a sequence of positive integers entered one per line. The program stops reading when integer ‘0’ is entered. The program will sort and output them into an ascending numerical order.For example: 5 1 7 12 36 8 0 Output: 1 5 7 8 12 36