2.99 See Answer

Question: Write an application that prompts the user


Write an application that prompts the user to enter an integer and displays its square root. Accept the user’s entry as a String using the nextLine() method. Then try to use the Integer.parseInt() method to convert the String to an integer. If the conversion throws an Exception, display an error message, and set the number to 0. Then, if the entered number is less than 0, throw an ArithmeticException to a catchblock that explains you cannot take the square root of a negative number. If the entered number is not less than 0, take the square root of the number using the Math.sqrt() method, and display the result. Save the file as SqrtException.java.

2.99

See Answer