import java.io.*; class Numbers2 { // Read a number of integers and store them in an array. // Find and print the biggest and smallest number and the average. static final int SENTINEL = -999; static final int MAXNUMS = 100; public static void main (String[] args) throws IOException { int [] data; int count,n; double average; BufferedReader in = Text.open(System.in); data = new int[MAXNUMS]; for(count=0; ;count++) { System.out.print("Enter number "+(count+1)+" (or "); System.out.print(SENTINEL+" to finish): "); n=Text.readInt(in); if(n==SENTINEL) break; data[count]=n; } System.out.println("The numbers entered were:"); NumberOps.printall(data,count); System.out.println("The biggest is: "+NumberOps.biggest(data,count)); System.out.println("The smallest is: "+NumberOps.smallest(data,count)); System.out.print("The position of the biggest is: "); System.out.println(NumberOps.posBiggest(data,count)+1); System.out.print("The position of the smallest is: "); System.out.println(NumberOps.posSmallest(data,count)+1); System.out.print("The average is: "); average=NumberOps.average(data,count); System.out.println(Text.writeDouble(average,5,3)); } }