import java.io.*; import javax.swing.JOptionPane; import javax.swing.JTextArea; import java.awt.Font; public class IO { // private static BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); public static void showMessage (String s) { JTextArea area = new JTextArea(s); area.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); JOptionPane.showMessageDialog (null, area); } public static void showValue (String s1, String s2) { IO.showMessage (s1+s2); } public static double readDouble (String prompt) { try { String s = JOptionPane.showInputDialog(prompt); return Double.parseDouble(s); } catch (Exception e) { return Double.NaN; } } public static float readFloat (String prompt) { try { String s = JOptionPane.showInputDialog (prompt); return (Float.parseFloat(s)); } catch (Exception e) { return Float.NaN; } } public static int readInt (String prompt) { try { String s = JOptionPane.showInputDialog (prompt); return (Integer.parseInt(s)); } catch(Exception e) { return Integer.MAX_VALUE; } } public static char readChar (String prompt) { String s = JOptionPane.showInputDialog(prompt); if (s == null) { return 0; } else if (s.length () > 0) return s.charAt (0); else return 0; } public static String readString (String prompt) { return (JOptionPane.showInputDialog (prompt)); } } // End of IO class