Question: Consider the program below which prints the larger of two positive integers: class Larger { static void FindLarger(int A, int B) { if(A>B){ System.out.println (A);

Consider the program below which prints the larger of two positive integers: class Larger { static void FindLarger(int A, int B) { if(A>B){ System.out.println (A); } else { System.out.println (B); } public static void main(String args[]) { int A = 2; int B=4; FindLarger(A,B); } } Modify the above program so that the Find Larger() method throws an IllegalArgumentException if either A or B is negative and informs the user that the inputs should be positive. A try and catch loop should also be added to catch the exception and output the exception that has been caught
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
