Advertisement
Guest User

CalcNumLength

a guest
Nov 13th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.50 KB | None | 0 0
  1. /**
  2.  *
  3.  * @author winf103738
  4.  */
  5. public class Zahl {
  6.  
  7.     static int zahl = 1000;
  8.  
  9.     /**
  10.      * @param args the command line arguments
  11.      */
  12.     public static void main(String[] args) {
  13.         System.out.println(calcNumLength(zahl));
  14.     }
  15.    
  16.     private static int calcNumLength(int num){
  17.         int count = 0;
  18.         while (num >= 10) {
  19.             num = num / 10;
  20.             count++;
  21.         }
  22.         if(num > 0){
  23.         count++;
  24.         }
  25.         return count;
  26.     }
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement