import javax.swing.*; import java.io.*; class DueColonneDouble { public static void main(String[] args) throws IOException { String stringaInput; double[] numeri = new double[10]; int i=0; while(i<numeri.length) { stringaInput = JOptionPane.showInputDialog( "Inserisci l'elemento in posizione " + i); try { numeri[i] = Double.parseDouble(stringaInput); i++; } catch(java.lang.NumberFormatException e) { } catch(java.lang.NullPointerException e) { JOptionPane.showMessageDialog(null, "Arrivederci!"); System.exit(0); } } File fileOutput = new File("miatabella.txt"); PrintWriter streamOutput = new PrintWriter(new FileWriter(fileOutput)); for(i=0; i<numeri.length/2; i++) streamOutput.println(numeri[2*i]+"\t"+numeri[2*i+1]); streamOutput.close(); System.exit(0); } }