Count the Digits

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:

Files Needed




©2003–2016 Graham Mitchell

This assignment is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.
Creative Commons License