Question: write a program that compute the power of a number by implementing a calculator. create a class calculator which consists of a single method long

write a program that compute the power of a number by implementing a calculator. create a class calculator which consists of a single method long power of(int, int). this method takes two integers, a and b, as parameters and finds ab. if either a or b is negative, then the method must throw an exception which says "negative values not allowed for a or b". also, if both a and b are zero, then the method must throw an exception which says "a and b should be zero." create a function power of in class calculator and return the appropriate result after the power operation or an appropriate exception has been handled. For example for -2 and -6 argument for powerOf would result in java.lang.Exception: negative values not allowed for a or b

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!