ExceptionExample2

ExceptionExample2 - + "divisor: "); //Line 5...

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 ExceptionExample2 { static Scanner console = new Scanner(System.in); public static void main(String[] args) { int dividend, divisor, quotient; //Line 1 System.out.print("Line 2: Enter the " + "dividend: "); //Line 2 dividend = console.nextInt(); //Line 3 System.out.println(); //Line 4 System.out.print("Line 5: Enter the "
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: + "divisor: "); //Line 5 divisor = console.nextInt(); //Line 6 System.out.println(); //Line 7 if (divisor != 0) //Line 8 { quotient = dividend / divisor; //Line 9 System.out.println("Line 10: " + "Quotient = " + quotient); //Line 10 } else System.out.println("Line 11: Cannot " + "divide by zero."); //Line 11 } }...
View Full Document

This note was uploaded on 06/17/2011 for the course COMP 2301 taught by Professor Staff during the Spring '10 term at Kennesaw.

Ask a homework question - tutors are online