Friday, November 27, 2009

Chapter 14 Exercise 3

import java.util.Scanner;

public class Division{
public static void main(String[] args){
Scanner stdIn = new Scanner(System.in);
int n, d, q;

try{
System.out.print("Enter numerator: ");
n = stdIn.nextInt();
System.out.print("Enter divisor: ");
d = stdIn.nextInt();
q = n / d;
System.out.println(q + "\n");
}

catch(ArithmeticException e){
System.out.println("Error, but keep going anyway,");
}
}//end of main
}//end of Division class

No comments:

Post a Comment