Professional Documents
Culture Documents
If parameter is >= 10 then the method should process the number and return sum of
all digits, otherwise return -1 to indicate an invalid value.
The numbers from 0-9 have 1 digit so we don�ft want to process them, also we don�ft
want to process negative numbers, so also return -1 for negative numbers.
Add some code to the main method to test out the sumDigits method to determine that
it is working correctly for valid and invalid values passed as arguments.
Hint:
Use n % 10 to extract the least-significant digit.
Use n = n / 10 to discard the least-significant digit.
The method needs to be static like other methods so far in the course.
Tip:
Create a project with the name DigitSumChallenge.