Code /* IOapalooza3.java CIS 260 David Klick 2006-01-18 This program demonstrates simple GUI I/O using JOptionPanes. It also demonstrates a simple input loop and basic data validation. */ import javax.swing.*; public class IOapalooza3 { public static void main(String[] args) { int sum = 0; String strIn = JOptionPane.showInputDialog("Enter an integer (QUIT to exit)"); while (!strIn.equalsIgnoreCase("QUIT")) { try { int num = Integer.parseInt(strIn); sum += num; } catch (NumberFormatException e) { JOptionPane.showMessageDialog(null, "Illegal integer", "Error", JOptionPane.ERROR_MESSAGE); } strIn = JOptionPane.showInputDialog("Enter an integer (QUIT to exit)"); } JOptionPane.showMessageDialog(null, "The total is " + sum, "Total", JOptionPane.INFORMATION_MESSAGE); System.exit(0); } }