/* Loops7.java CIS 160 David Klick 2004-09-17 Demonstrates error checking with continue and break */ import javax.swing.JOptionPane; public class Loops7 { public static void main(String[] args) { String strIn; int num; do { strIn = JOptionPane.showInputDialog("Enter an integer (Q to quit)"); if (strIn == null) { System.out.println("Nothing was entered"); continue; } System.out.println("You entered: " + strIn); if (strIn.equalsIgnoreCase("Q")) break; try { num = Integer.parseInt(strIn); System.out.println("The number is " + num); } catch (NumberFormatException e) { System.out.println("Invalid integer entered"); } } while (true); System.exit(0); } }