/* * Demonstrates how to use loops * @author Pete Nordquist * @version 100114 */ public class W02N03 { public static void main(String[] args) { // example: // print all integers in the range the user specifies: // if user specifies a low of 3 and a high of 6, program should print: 3, 4, 5, 6 // declare variables to hold user responses int low; int high; // read and store values from user System.out.print("low value> "); low = TextIO.getlnInt(); System.out.print("high value> "); high = TextIO.getlnInt(); // declare variable to hold the current number int current; // initialize current to the low value current = low; // print a descriptive header line System.out.println("The individual integers in your range are: "); // loop while there is still some value to print while (current <= high) { System.out.print(current); // print ", " if we need it if (current < high) System.out.print(", "); // increment current current = current + 1; } } }