import java.util.Scanner; import java.util.NoSuchElementException; import java.util.InputMismatchException; public class ExceptionHandling { public static void main(String []args) { Scanner sc = new java.util.Scanner(System.in); try { System.out.print("Width: "); int width = sc.nextInt(); System.out.print("Height: "); int height = sc.nextInt(); double ratio = width / (double)height; System.out.format("Ratio: %.2f", ratio); sc.close(); } catch(InputMismatchException ex) { System.out.println("Input doen not match integer value."); } catch(NoSuchElementException ex) { System.out.println("You have closed the input from command line."); } } }