forked from krimanisha/Hacktoberfest21
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavaOutputFormatting.java
More file actions
39 lines (29 loc) · 1.11 KB
/
JavaOutputFormatting.java
File metadata and controls
39 lines (29 loc) · 1.11 KB
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
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("================================");
int count;
for(int i=0; i<3 ;i++){
String s1 = sc.next();
int x = sc.nextInt();
System.out.print(s1);
if (s1.length() < 15){
count = s1.length();
count = 15 - s1.length();
for (int j = 0; j < count; j++){
System.out.print(" ");
}
}
if (x < 10){
System.out.println("00" + x);
} else if (x < 100){
System.out.println("0" + x);
} else {
String s = Integer.toString(x);
System.out.println(s.substring(0,3));
}
}
System.out.println("================================");
}
}