ExceptionExample4

ExceptionExample4 - + "\nQuotient...

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

View Full Document Right Arrow Icon
Oimport javax.swing.J±ptionPane; 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 = J±ptionPane.showInputDialog ("Enter the dividend: "); //Line 5 dividend = Integer.parseInt(inpStr); //Line 6 inpStr = J±ptionPane.showInputDialog ("Enter the divisor: "); //Line 7 divisor = Integer.parseInt(inpStr); //Line 8 quotient = dividend / divisor; //Line 9 J±ptionPane.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", JptionPane.INFRMATIN_MESSAGE); //Line 10 } catch (ArithmeticException aeRef) //Line 11 { JptionPane.showMessageDialog(null, "Line 12: Exception " + aeRef.toString(), "ArithmeticException", JptionPane.ERRR_MESSAGE); //Line 12 } catch (NumberFormatException nfeRef) //Line 13 { JptionPane.showMessageDialog(null, "Line 14: Exception " + nfeRef.toString(), "NumberFormatException", JptionPane.ERRR_MESSAGE); //Line 14 } System.exit(0); //Line 15 } }...
View Full Document

Ask a homework question - tutors are online