COMP: (Please use Java) For the NumberWords.java in Resources,rewrite the Java class (i) to accept input from a keyboard onenumber at a time. (As it currently stands, the Scanner uses astring to simulate a user keyboard activity, which you will modifyto take input from the keyboard). (ii) if the user enters anythingother than an integer value, then raise an appropriate exception bya try () catch() block, and (iii) in the case of wrong user input,allow maximum of three tries to be made by the user to input aproper integer value , (iv) After three tries, the programterminates with an error message saying “maximum number of attemptsexceeded”, and (v) the program terminates if the user types “done”at any time. Make sure to prompt the user to enter the inputappropriately each time. You will submit only the NumberWords.javafile. import java.util.*; // for the Scanner classpublic class NumberWords{ public static void main (String[] args) { new NumberWords().run(); } // main public void run() { final String NUMBER_WORDS_MESSAGE = “nAnswer: “; Scanner sc = new Scanner (“805 17n22z2n-7n395nx 5n0”); while (sc.hasNext()) System.out.println (NUMBER_WORDS_MESSAGE + getNumberWords (sc)); } // method run public String getNumberWords (Scanner sc) { try { String[ ] digitWords = {“zero “, “one “, “two “, “three “, “four “, “five “, “six “, “seven “, “eight “, “nine “}; int number = sc.nextInt(), saveNumber = number, digit; String sign = “”, numberWords = “”; if (number < 0) { sign = “minus “; number = -number; } // if negative number if (number == 0) numberWords = “zero “; while (number > 0) { digit = number % 10; number = number / 10; numberWords = digitWords [digit] + numberWords; } // while return Integer.toString (saveNumber) + ” is ” + sign + numberWords; } // try catch (InputMismatchException e) { return e.toString() + “: ” + sc.next( ) + ” is not an int.”; } // catch InputMismatchException } // method getNumberWords } // class NumberWords . . .

"Get 15% discount on your first 3 orders with us"
Use the following coupon
"FIRST15"

Order Now