Question: JAVA Write a method that takes 2 integer numbers a and b and returns a value of type double. The method returns 0 when either

JAVA

Write a method that takes 2 integer numbers a and b and returns a value of type double.

  • The method returns 0 when either of the two parameters is negative.
  • The method returns a raised to the power of b if the largest of parameters is a one-digit number (it is in the range [0, 9])
  • The method returns a product of a and b if the largest of two numbers is a two-digit number (it is in the range [10, 99])
  • The method returns 10000 when the largest of two parameters is a number that has 3 or more digits.

Method header: public static double problem01(int a, int b)

Add Java Doc comments before the method header.

Unit tests for the method are provided.

Sample method calls:

problem01(2, 3) => returns 8.0 problem01(9, 1) => returns 9.0 problem01(9, 0) => returns 1.0 problem01(9, 10) => returns 90.0 problem01(10, 1) => returns 10.0 problem01(22, 10) => returns 220.0 problem01(222, 10) => returns 10000.0 problem01(0, 1000) => returns 10000.0 problem01(-1, 1000) => returns 0.0

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!