submit the following files:
Consider the following code:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = newScanner(System.in);
String input = \"\";
System.out.println(\"Enter the firstnumber: \");
input = in.nextLine();
int a = 0;
int b = 0;
a = Integer.parseInt(input);
System.out.println(\"Enter the secondnumber: \");
input = in.nextLine();
b = Integer.parseInt(input);
int result = 0;
result = a/b;
System.out.println(\"a/b : \" +result);
}
Copy the code to your Main.java file and run it with thefollowing inputs:
34 and 0;
‘Thirty-four’ as the first input.
What prevented the program from running successfully?
Update the code, so that it can handle cases a) and b).
Please note the following:
You have to use try-catch to handle exceptions. You willget zero credit otherwise;
To determine exception classes, that you need to catch, useerror message from the respective case (a) and b)). Hint: to handleString-to-integer conversion, use NumberFormatException;
Exceptions should be caught so that:
Code never crashes due to non-numeric input (both for first andsecond values);
Code never crashes due to division by zero;
If non-numeric value is entered for a or b, program shouldoutput \"Error: entered value is not an integer number. Exiting...\"and exit (use System.exit(0); to exit);
If zero value is entered for b, program should output \" Error:cannot divide by zero. Exiting...\" and exit (use System.exit(0); toexit);
Hints: Use 3 try-catch blocks in total. Try block should onlycontain the command, that can throw an exception.
PLEASE FOLLOW ALL THE INSTRUCTIONSPRECISELY