-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIfExercise2.java
More file actions
42 lines (37 loc) · 997 Bytes
/
IfExercise2.java
File metadata and controls
42 lines (37 loc) · 997 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package exercise_if;
import static java.lang.Integer.*;
import static java.lang.String.*;
import static java.lang.System.*;
import static yan_service.YANConstant.*;
import static yan_service.YANService.*;
public class IfExercise2 {
public static void main(String[] args) {
// tit
out.println(BLUE_BOLD);
printlnAdv("If Exersice 2");
// content
run();
}
// Main
private static void run() {
// input
out.println();
printAdv(GREEN, "Nhập vào số tự nhiên: ", RESET);
var n = numLimit(0, MAX_VALUE);
// output
printlnAdv(YELLOW, format("Số %d có %d chữ số.", n, numCounter(n)));
out.println();
// ctrl
checkOut();
}
// Number counter
private static int numCounter(int n) {
return String.valueOf(n).length();
}
// Check out
private static void checkOut() {
if (credit() == 1) {
run();
}
}
}