@@ -0,0 +1,872 @@
+package com.hackerrank.contests.daysOfCode_30;%0A%0Aimport java.util.Scanner;%0A%0Aclass Calculator %7B%0A%09int power(int n, int p) throws Exception %7B%0A%09%09Integer output = null;%0A%09%09if (n %3E -1 && p %3E -1) %7B%0A%09%09%09output = (int) Math.pow(n, p);%0A%09%09%7D else %7B%0A%09%09%09//output = Integer.parseInt(%22n and p should be non-negative%22);%0A%09%09%09throw new Exception(%22n and p should be non-negative%22);%0A%09%09%7D%0A%09%09return output;%0A%09%7D%0A%7D%0A%0Apublic class Day17_Exceptions %7B%0A%0A%09public static void main(String%5B%5D args) %7B%0A%09%09// TODO Auto-generated method stub%0A%0A%09%09@SuppressWarnings(%22resource%22)%0A%09%09Scanner in = new Scanner(System.in);%0A%09%09int T = in.nextInt();%0A%09%09while (T-- %3E 0) %7B%0A%09%09%09int n = in.nextInt();%0A%09%09%09int p = in.nextInt();%0A%09%09%09Calculator myCalculator = new Calculator();%0A%09%09%09try %7B%0A%09%09%09%09int ans = myCalculator.power(n, p);%0A%09%09%09%09System.out.println(ans);%0A%0A%09%09%09%7D catch (Exception e) %7B%0A%09%09%09%09System.out.println(e.getMessage());%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%7D%0A%0A%7D%0A

Create Day17_Exceptions.java