Write a static method that is passed an integer and returns the sum of the digits of that integer. You will need to use modulus inside a loop.
Preconditions:
Examples:
sumDigits(123)
returns 6
(1+2+3)sumDigits(45454)
returns 22
(4+5+4+5+4)sumDigits(111111111)
returns 9
(1+1+1+1+1+1+1+1+1)©2003–2016 Graham Mitchell
This assignment is licensed under a
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.