// Illustrate use of a while-loop to read an arbitrary // number of values interactively from the user. // The end of the input is indicated when the value -1 is read. class BarChartMain2 { public static void main(String[] args){ SimpleInput reader = new SimpleInput(); // Use a minder to check sensible use of the BarChart. // The chart displays values in the range [1..100] BarChartMinder minder = new BarChartMinder(new BarChart()); // The value on which to stop. int terminatingValue = -1; System.out.println("Please input the values, use "+ terminatingValue+" to finish."); int value = reader.nextInt(); while(value != terminatingValue){ minder.addToChart(value); value = reader.nextInt(); } } }