ExceptionExample3

ExceptionExample3 - //Line 8 System.out.println(); //Line 9...

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

View Full Document Right Arrow Icon
import java.util.*; i public class ExceptionExample3 { static Scanner console = new Scanner(System.in); public static void main(String[] args) //Line 1 { int dividend, divisor, quotient; //Line 2 try //Line 3 { System.out.print("Line 4: Enter the " + "dividend: "); //Line 4 dividend = console.nextInt(); //Line 5 System.out.println(); //Line 6 System.out.print("Line 7: Enter the " + "divisor: "); //Line 7 divisor = console.nextInt();
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: //Line 8 System.out.println(); //Line 9 quotient = dividend / divisor; //Line 10 System.out.println("Line 11: Quotient = " + quotient); //Line 11 } catch (ArithmeticException aeRef) //Line 12 { System.out.println("Line 13: Exception " + aeRef.toString()); //Line 13 } catch (InputMismatchException imeRef) //Line 14 { System.out.println("Line 15: Exception " + imeRef.toString()); //Line 15 } } }...
View Full Document

Ask a homework question - tutors are online