-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprint formatted output.java
More file actions
49 lines (44 loc) · 1.61 KB
/
print formatted output.java
File metadata and controls
49 lines (44 loc) · 1.61 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
37
38
39
40
41
42
43
44
45
46
47
48
49
import java.util.*;
public class Solution {
public static void main(String[] args) {
int c=0,dig,n,j;
Scanner sc=new Scanner(System.in);
System.out.println("================================");
for(int i=0;i<3;i++){
String s1=sc.next();
int x=sc.nextInt();
n=x;
while(n>0){
dig= n%10;
n=n/10;
c++;
}
System.out.print(s1);
for(j=s1.length()+1;j<=18;j++){
if(j==16&&x==0)
System.out.print("0");
else if(j==17&&x==0)
System.out.print("0");
else if(j==18&&x==0)
System.out.print("0");
if(j==16&&c==1)
System.out.print("0");
else if(j==17&&c==1)
System.out.print("0");
else if(j==18&&c==1)
System.out.print(x);
else if(j==16&&c==2)
System.out.print("0");
else if(j==17&&c==2)
System.out.print(x);
else if(j==16&&c==3)
System.out.print(x);
else if(j<16)
System.out.print(" ");
}
System.out.println();
c=0;
}
System.out.println("================================");
}
}