forked from Dhruv09d/Hacktoberfest2021
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SevenSegment.java
46 lines (37 loc) · 1015 Bytes
/
SevenSegment.java
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
package beginner;
import java.util.Scanner;
public class SevenSegment {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner s = new Scanner(System.in);
int t=s.nextInt();
int a[]={6,2,5,5,4,5,6,3,7,6};
while(t-->0){
int n=s.nextInt();
int d=0;
if(n==0){
System.out.print(111);
continue;
}
while(n!=0){
int p=n%10;
d+=a[p];
n=(int)(n/10);
}
int c=(int)(d/2);
if(d%2==0){
while(c-->0){
System.out.print(1);
}
}else{
c--;
System.out.print(7);
while(c-->0){
System.out.print(1);
}
}
System.out.println();
}
s.close();
}
}