{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

ExceptionExample4 - "\nQuotient ="...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Oimport javax.swing.JOptionPane; i public class ExceptionExample4 { public static void main(String[] args) //Line 1 { int dividend, divisor, quotient; //Line 2 String inpStr; //Line 3 try //Line 4 { inpStr = JOptionPane.showInputDialog ("Enter the dividend: "); //Line 5 dividend = Integer.parseInt(inpStr); //Line 6 inpStr = JOptionPane.showInputDialog ("Enter the divisor: "); //Line 7 divisor = Integer.parseInt(inpStr); //Line 8 quotient = dividend / divisor; //Line 9 JOptionPane.showMessageDialog(null, "Line 10:\nDividend = " + dividend + "\nDivisor = " + divisor
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: + "\nQuotient =" + quotient, "Quotient", J±ptionPane.INF±RMATI±N_MESSAGE); //Line 10 } catch (ArithmeticException aeRef) //Line 11 { J±ptionPane.showMessageDialog(null, "Line 12: Exception " + aeRef.toString(), "ArithmeticException", J±ptionPane.ERR±R_MESSAGE); //Line 12 } catch (NumberFormatException nfeRef) //Line 13 { J±ptionPane.showMessageDialog(null, "Line 14: Exception " + nfeRef.toString(), "NumberFormatException", J±ptionPane.ERR±R_MESSAGE); //Line 14 } System.exit(0); //Line 15 } }...
View Full Document

{[ snackBarMessage ]}