JAVA Program to Check Number is Divisible by 19 or Not

JAVA Program to Check Number is Divisible by 19 or Not:


 import java.io.*;
 class No_not_divisible extends Exception
 {
   No_not_divisible(String s)
   {
     super(s);
   }
 }

 class ckeck_divisible
 {
  public static void main(String args[])throws IOException
  {
   try
   {
    int no;
    no=Integer.parseInt(args[0]);
    System.out.println("Entered Number is: "+no);
    if(no%19==0)
     System.out.println("Divisible by 19");
    else
     throw new No_not_divisible("Not valid number");

   }
   catch(No_not_divisible e)
   {
       System.out.println(e);
   }
  }
 }

OUTPUT:

Entered Number is: 32
No_not_divisible: Not valid number

Entered Number is: 38
Divisible by 19



Leave a Reply

Your email address will not be published. Required fields are marked *

nine + two =