Programming Tutorials

(追記) (追記ここまで)

How to count the number of digits in any Input number other than negative numbers

By: Ganesh Iyer in Java Tutorials on 2009年05月28日 [フレーム]

import java.io.*;
class constplaceCount
{
 int cnt;
 int numPlace(int num)
 {
 while (num> 0 )
 {
 int r = num % 10;
 cnt++;
 num = num / 10;
 System.out.println(\"The number\"+num);
 }
 return cnt;
 }
}
class placeCount
{
 public static void main(String[] args)
 {
 int cnt;
 constplaceCount n = new constplaceCount();
 cnt = n.numPlace(50);
 System.out.println(\"The count of the number places \"+cnt);
 }
}



(追記) (追記ここまで)


Add Comment

JavaScript must be enabled for certain features to work
* Required information
1000

Comments

No comments yet. Be the first!
(追記) (追記ここまで)
(追記) (追記ここまで)

AltStyle によって変換されたページ (->オリジナル) /