// Online question from the sample final exam // This is the first cut at getting something working // I'd submit this when it worked and then keep going // Note the read before the loop and then at the bottom // Beth Katz - April 2009 import java.util.Scanner; public class Final0 { final static int MaxItems = 100; public static void main(String[ ] args) { int[ ] items = new int[MaxItems]; int count = 0; int amount; Scanner input = new Scanner(System.in); System.out.println("Please enter the inventory amounts:"); amount = input.nextInt( ); // read before loop while (amount >= 0) { items[count] = amount; count++; amount = input.nextInt( ); // read at bottom of loop } System.out.println(count + " items read."); } }