/* This is a program that demonstrates arrays: declaration, reading and writing. Laura Toma csci107 */ public class ReadArray { public static void main (String args[]) { //setting up the variable that reads from user ReadStream r = new ReadStream(); int NB_ELEMENTS; System.out.println("Number of elements: "); NB_ELEMENTS = r.readInt(); r.readLine(); //declare an array of NB_ELEMENTS elements int a[] = new int [NB_ELEMENTS]; //read the elements in the array from the user int i = 0; while (i < a.length) { System.out.println("Enter element " + i + ": "); a[i] = r.readInt(); r.readLine(); i = i+1; } //print the elements in the array to the user i = 0; while (i < a.length) { System.out.println("Element " + i + "=" + a[i]); i = i+1; } } // end of main } // end of class