importjava.io.*;classKW{publicstaticvoidmain(Stringargs[]){System.out.println("———————————————————————————————————————————");System.out.println("Program for exceptional handling");System.out.println("———————————————————————————————————————————");try{BufferedReaderr=newBufferedReader(newInputStreamReader(System.in));System.out.print("Enter numerator ");intn=Integer.parseInt(r.readLine());System.out.print("Enter denominator ");intd=Integer.parseInt(r.readLine());System.out.println("Division "+(n/d));}catch(Exceptione){System.out.println("Please enter valid input");}System.out.println("———————————————————————————————————————————");}}
Output
kodingwindow@kw:~$ javac KW.java kodingwindow@kw:~$ java KW
———————————————————————————————————————————
Program for exceptional handling
———————————————————————————————————————————
Enter numerator 515
Enter denominator 0
Please enter valid input
———————————————————————————————————————————
kodingwindow@kw:~$ java KW
———————————————————————————————————————————
Program for exceptional handling
———————————————————————————————————————————
Enter numerator 515
Enter denominator 5
Division 103
———————————————————————————————————————————
kodingwindow@kw:~$
Dear User, Thank you for visitng Kodingwindow. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.
Dear User, We are grateful for your interest in the Kodingwindow Android app. We intend to soon make it available on the Google Play Store. Currently, Android versions 10 and up require manual apk installations. Would you like to get the app?