Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 12c SQL

Authors: Joan Casteel

3rd edition

1305251032, 978-1305251038

More Books

Students also viewed these Databases questions