Question
3) Write a static method and a test program for a method called digitRange() that takes an integer n as an argument and returns the
3) Write a static method and a test program for a method called digitRange() that takes an integer n as an argument and returns the largest difference between the individual digits in the number. For example the call digitRange(68437) should return 5 because the largest difference between individual digits is (8 - 3). You should test whether the number passed to the method is >= 0 and throw an IllegalArgumentException if not. Passing a 1 digit number should return a 0 (zero). You must test these cases: Method Call Value Returned digitRange(0) 0 digitRange(26) 4 digitRange(42) 2 digitRange(888) 0 digitRange(1234) 3 digitRange(24680) 8 digitRange(857492) 7 You can use any techniques you want, including Strings to inspect the individual digits. (25 pts) To get full credit, you must show the 7 test values defined above
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started