We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
importjava.io.*;importjava.util.*;publicclassSolution{publicstaticvoidmain(String[]args){/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */Scannerinput=newScanner(System.in);intx;inty;try{x=input.nextInt();y=input.nextInt();floatresp=x/y;if(resp%10==0){System.out.println(Math.round(resp));}else{System.out.println(y);}}catch(InputMismatchExceptione){System.out.println(e.getClass().toString().substring(6));}catch(ArithmeticExceptiona){System.out.println(a);}}}
Java Exception Handling (Try-catch)
You are viewing a single comment's thread. Return to all comments →