package class6_1_Exceptions; import javax.swing.JOptionPane; import java.util.jar.JarEntry; public class ProblemCode { public static void main(String[] args) { doStuff(); } private static void doStuff() { String numerString = "something other than q"; String denomString = "will be overwritten"; if(numerString != null && denomString != null) { while (!numerString.toLowerCase().equals("q")) { int numer; int denom; try { numer = Integer.parseInt(numerString); denom = Integer.parseInt(denomString); if (denom != 0) { double fraction = numer / denom; JOptionPane.showMessageDialog(null, "Fraction: " + fraction); } } catch (NumberFormatException e) { String message = "Oh no, that's not an integer!" + " entered:" + numerString + "/" + denomString; System.out.println(message); JOptionPane.showMessageDialog(null, message); } numerString= JOptionPane.showInputDialog( null,"Please enter the numerator (or q to quit):"); denomString = JOptionPane.showInputDialog(null,"Please enter the denominator:"); } // while not q entered } // if not null } // doSomething method } // class