Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class DuplicateElimination {
- public static void main(String[] args) {
- int unique[] = new int [5];
- int counter = 0;
- Scanner input = new Scanner(System.in);
- while(counter < unique.length)
- {
- System.out.println("Enter number between 10 and 100.");
- int num = input.nextInt();
- if(num >= 10 && num <= 100)
- {
- boolean not = false;
- for(int i = 0; i < unique.length; i++)
- {
- if(num == unique[i])
- {
- not = true;
- }
- }
- if(!not)
- {
- unique[counter] = num;
- counter++;
- System.out.println(num + " is added.");
- }
- else
- {
- System.out.println(num + " has been entered.");
- }
- }
- else
- {
- System.out.println("Numbers should be between 10 and 100.");
- }
- System.out.println("The current numbers are: ");
- for(int i = 0; i < counter; i++)
- {
- System.out.println(unique[i] + " ");
- }
- System.out.println("\n");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement