Thursday 25 January 2018

Exceptional handling example in java

import java.io.*;

public class ExceptionalExample 
{
        public static void main(String [ ] args) throws IOException
       {
         InputStreamReader isr = new InputStreamReader(System.in);
         BufferedReader  br = new BufferedReader(isr);
         System.out.println("Enter a number");
         String str = br.readLine();
        
         int a = Integer.parseInt(str);
        
         int c = 100/a;
        
         System.out.println("You have Entered: "+ str +" after division : "+c);
                                                         
       }
}

0 comments: