throwing exceptions java

Solutions on MaxInterview for throwing exceptions java by the best coders in the world

showing results for - "throwing exceptions java"
Davide
11 Jul 2020
1/* In this program we are checking the Student age
2 * if the student age<12 and weight <40 then our program 
3 * should return that the student is not eligible for registration.
4 */
5public class ThrowExample {
6   static void checkEligibilty(int stuage, int stuweight){ 
7      if(stuage<12 && stuweight<40) {
8         throw new ArithmeticException("Student is not eligible for registration"); 
9      }
10      else {
11         System.out.println("Student Entry is Valid!!"); 
12      }
13   } 
14
15   public static void main(String args[]){ 
16     System.out.println("Welcome to the Registration process!!");
17     checkEligibilty(10, 39); 
18     System.out.println("Have a nice day.."); 
19 } 
20}