下载后可任意编辑实验 7 异常处理与异常类一. 实验目的及实验环境 1 理解 Java 异常的基本概念和处理机制。 2 掌握 Java 异常处理的方法( 抛出和捕获异常; try、 throw、 throws、 catch 语句和 finally 的用法) 3 理解异常类的作用, 掌握创立异常类的方法。二. 实验内容 1 基本内容( 实验前请及时熟悉如下相关内容) 1) Java 的异常处理机制2) 异常类的应用3) 常见的异常(除数为零等)4) 多异常处理5) 由方法抛出异常6) 必须要捕获的异常 2 综合实验: 2.1 (Y. Daniel Liang英文版第10版P488: 12.2* (InputMismatchException)) (Y. Daniel Liang英文版八版P456: 13.2*) (NumberFormatException) Write a program that prompts the user to read two integers and displays their sum. Your program should prompt the user to read the number again if the input is incorrect.2.2 (Y. Daniel Liang英文版第10版P488: 12.3* ) (Y. Daniel Liang英文版八版P456: 13.3*) (ArrayIndexOutBoundsException) Write a program that meets 下载后可任意编辑the following requirements:■ Create an array with 100 randomly chosen integers.■ Prompt the user to enter the index of the array, then display the corresponding element value. If the specified index is out of bounds, display the message Out of Bounds.2.3 (Y. Daniel Liang英文版第10版P488: 12.4* ) (Y. Daniel Liang英文版八版P456: 13.4*) (IllegalArgumentException) Modify the Loan class in Listing 10.2 to throw IllegalArgumentException if the loan amount, interest rate, or number of years is less than or equal to zero.2.4 (Y. Daniel Liang英文版第10版P488: 12.5* ) (Y. Daniel Liang英文版八版P456: 13.5*) (IllegalTriangleException) Exercise 11.1 defined the Triangle class with three sides. In a triangle, the sum of any two sides is greater than the other side. The Triangle class must adhere to this rule. Create the IllegalTriangleException class, and modify the constructor of the Triangl...