-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEm.java
More file actions
89 lines (82 loc) · 1.67 KB
/
Em.java
File metadata and controls
89 lines (82 loc) · 1.67 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import java.util.*;
public class Em {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int id[]=new int[6];
String n[]=new String[6];
int d[]=new int[6];
for(int i=0;i<6;i++)
{
System.out.println("Id");
id[i]=sc.nextInt();
System.out.println("Name");
n[i]=sc.next();
System.out.println("Login date");
d[i]=sc.nextInt();
}
System.out.println("Id");
for(int j=0;j<6;j++)
System.out.println(id[j]);
System.out.println("Name");
for(int j=0;j<6;j++)
System.out.println(n[j]);
System.out.println("Login Date");
for(int j=0;j<6;j++)
System.out.println(d[j]);
for(int w=0;w<5;w++)
for(int y=0;y<(5-w);y++)
if(d[y]>d[y+1])
{
int k=d[y];
d[y]=d[y+1];
d[y+1]=k;
int r=id[y];
id[y]=id[y+1];
id[y+1]=r;
}
/**System.out.println("Id");
for(int i=0;i<6;i++)
System.out.println(id[i]);
System.out.println("Date");
for(int i=0;i<6;i++)
System.out.println(d[i]);*/
System.out.println("Id for 3 consecutive login date");
int h=0;
int a=0;
int ad=0;
for(int t=0;t<6;t++)
{
if(id[t]>=h)
{
h=id[t];
if(h==id[t])
a++;
if(a==2)
{
ad=id[t];
System.out.println(ad);
}
}
}
System.out.println("Id");
for(int i=0;i<6;i++)
System.out.println(id[i]);
System.out.println("Id for non consecutive login dates");
int c2=0;
for(int w1=0;w1<6;w1++)
{
for(int w3=1;w3<6;w3++)
{
if(id[w1]==id[w3])
{
if(id[w3]!=ad)
{
c2++;
}
}
}
if(c2>1)
System.out.println(id[w1]);
}
}
}