import java .util.*;
import java.io.*;
public class DivisionPractice
{
 //this will compute the numerator and divisor 
public static int quotient(int x ,int y,int div)throws ArithmeticException{
public static void main (String[] args )
{
Scanner scan = new Scanner(System.in);
char a='m';
  do{
System.out.print("Enter numerator>:");
x = scan.nextInt();
  char x=n.charAt(0);
   try{
   //program will exit if x= 'q'or'Q'
   if(x=='q'||x=='Q'){
   System.exit(0);
   else{
System.out.print("Enter divisor>:");
   }
y = scan.nextInt();
  char y=d.charAt(0);
}
    //program will exit if y= 'q' or 'Q', 
    if(y=='q'||y=='Q'){
     System.exit(0);
    }else{
divide();
}
div = x / y;
System.out.println("The divide is >:" + div);
return div;
}
}
 catch(NumberFormatException numberFormat){
    //print the error message 
    System.err.printf("\nIncompatible type.\nPlease try again.");
  }
  catch(ArithmeticException arithmetic){
    //convert the String value and store in  num
    num=Integer.parseInt(n);
    //print the error message
    System.err.printf("\nYou can't divide "+num+" by 0");
  }
 }
Friday, March 13, 2009
Subscribe to:
Post Comments (Atom)
 
No comments:
Post a Comment