Day 17: More Exceptions - HackerRank 30 days of code solution
Objective Yesterday's challenge taught you to manage exceptional situations by using try and catch blocks. In today's challenge, you're going to practice throwing and propagating an exception. Check out the Tutorial tab for learning materials and an instructional video! Task Write a Calculator class with a single method: int power(int,int) . The power method takes two integers, and , as parameters and returns the integer result of . If either or is negative, then the method must throw an exception with the message: n and p should be non-negative . Note: Do not use an access modifier (e.g.: public) in the declaration for your Calculator class. Input Format Input from stdin is handled for you by the locked stub code in your editor. The first line contains an integer, , the number of test cases. Each of the subseq...























Comments
Post a Comment