import java.awt.*;import javax.swing.*;import java.util.*;import java.lang.String.*;public class Problem230{ public static void main (String args[]) {// JOptionPane prompt = new JOptionPane();// String input="";// OLD VERSION// /* we willl use a boolean var to determine if the input is valid// or not */// boolean valid = false;//// /* while the input is not exactly 5 chars, keep asking */ // while (!valid)// {// input = prompt.showInputDialog(null,"Whats the number to dissect, Chief?"); // /* unless the input is exactly 5 chars, we keep looping */// if (input.length()==5)// valid = true;// else// prompt.showMessageDialog(null,"Error: input length != 5.");// }// String[] output= new String[input.length()]; // prompt.showMessageDialog(null,"your number is "+input+", is it not?");// for (int i=0; i<input.length(); i++)// {// output[i] = input.charAt(i)+" ";// System.out.print(output[i]);// }// System.out.println();// System.exit(0);//*/ JOptionPane prompt = new JOptionPane(); String input=""; input = prompt.showInputDialog(null,"Whats the number to dissect, Chief?"); String[] output= new String[input.length()]; prompt.showMessageDialog(null,"your number is "+input+", is it not?"); try { for (int i=0; i<=4; i++) { output[i] = input.charAt(i)+" "; System.out.print(output[i]); } } catch ( StringIndexOutOfBoundsException e ) { System.out.println(); System.out.println("Error: input != 5 characters."); } }}