Write a static method that is passed an integer and returns how many digits the number has. For example, 33
has two digits.
There are three "good" ways to do this. Dividing the number over and over in a loop, converting to a String, and using logarithms. Use whichever one you like.
Preconditions:
Examples:
countDigits(123)
returns 3
countDigits(45454)
returns 5
countDigits(111111111)
returns 9
©2003–2016 Graham Mitchell
This assignment is licensed under a
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.