Skip to content

Commit de4b2be

Browse files
authored
Use public class
1 parent 3b7dae8 commit de4b2be

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

Maths/CountDigit.java

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
import java.util.*;
21
package Maths;
2+
3+
import java.util.*;
4+
35
// count the number of digits in a number
4-
class CountDigit {
5-
public static void main(String args[]) {
6-
Scanner sc = new Scanner(System.in);
7-
System.out.print("Enter the number: ");
8-
int number = sc.nextInt();
9-
int digits = 0;
10-
if(number == 0)
11-
{
12-
System.out.println("The number of digits present in the number: 1");
13-
}
14-
else
15-
{
16-
digits = (int)Math.floor(Math.log10(Math.abs(number)) + 1);
17-
System.out.println("The number of digits present in the number: " + digits);
18-
}
6+
public class CountDigit {
7+
public static void main(String args[]) {
8+
Scanner sc = new Scanner(System.in);
9+
System.out.print("Enter the number: ");
10+
int number = sc.nextInt();
11+
int digits = 0;
12+
if(number == 0){
13+
System.out.println("The number of digits present in the number: 1");
14+
}
15+
else
16+
{
17+
digits = (int)Math.floor(Math.log10(Math.abs(number)) + 1);
18+
System.out.println("The number of digits present in the number: " + digits);
1919
}
20-
}
20+
}
21+
}

0 commit comments

Comments
 (0)