// a generalized for loop import javax.swing.JOptionPane; public class ForLoopsGeneral { public static void main( String[] args ) { int index, begin, end, step, counter; // Prompt the user to enter the starting number String numString1 = JOptionPane.showInputDialog(null, "What is the first number? ", "Input Number Window", JOptionPane.QUESTION_MESSAGE); // Convert the string into an int value begin = Integer.parseInt(numString1); // Prompt the user to enter the ending number String numString2 = JOptionPane.showInputDialog(null, "What is the last number or highest possible? ", "Input Number Window", JOptionPane.QUESTION_MESSAGE); // Convert the string into an int value end = Integer.parseInt(numString2); // Prompt the user to enter the increment String numString3 = JOptionPane.showInputDialog(null, "What is the increment to use? ", "Input Number Window", JOptionPane.QUESTION_MESSAGE); // Convert the string into an int value step = Integer.parseInt(numString3); // "for" loop for(counter= begin; counter <= end; counter+=step) { System.out.println("The value of counter is " + counter); } System.exit( 0 ); } // end main } // end of program