Visit www.myprogramminglab.com to complete select exercises online and get instant feedback.
Exercise
Here is a snippet of code that inputs two integers and divides them:
Scanner scan = new Scanner(System.in);int n1, n2; double r;n1 = scan.nextInt();n2 = scan.nextInt();r = (double) n1 / n2;
Place this code into a try-catch block with multiple catches so that different error messages are printed if we attempt to divide by zero or if the user enters textual data instead of integers (java.util.InputMismatchException). If either of these conditions occurs, then the program should loop back and let the user enter new data.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.