-
Notifications
You must be signed in to change notification settings - Fork 0
/
Duplicate.java
66 lines (58 loc) · 1012 Bytes
/
Duplicate.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
Omar Aguirre
Duplicate
12-4-18
*/
import java.util.Scanner;
public class Duplicate {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int[] array = new int [5];
int a = 0;
int d = 0;
do {
System.out.println("Insert an integer: ");
int num = input.nextInt();
if(num > 9 && num < 101) {
boolean b = false;
a++;
for(int i = 0; i < array.length; i++) {
if (array[i] == num)
b = true;
}
if (!b) {
array[d] = num;
d++;
}
else
System.out.println("Integer was already entered!");
}
else
System.out.println("Invalid number!");
for(int i = 0; i< a; i++) {
if (array[i] != 0)
System.out.print(array[i] + " ");
}
System.out.println();
}
while (a < array.length);
}//body
}// main
/*
Insert an integer:
12
12
Insert an integer:
13
12 13
Insert an integer:
12
Integer was already entered!
12 13
Insert an integer:
14
12 13 14
Insert an integer:
15
12 13 14 15
*/