Friday 22 January 2010

User enters the ten numbers the program will make sure that all the numbers entered by the user are unique.

public class unique{

public static void main(String [] args){

int [] myarray=new int [10];

int c=0,i=0,x=0;

SimpleInput y;

y=new SimpleInput();

while(c<10){

x=y.getInt("Enter Number");

myarray[c]=x;

while(i>0){

i--;

if(x==myarray[i]){

x=y.getInt("You have already entered this number, enter new number");

}

}

myarray[c]=x;

System.out.println(myarray[c]);

c++;

i=c;

}

}

}

No comments:

Post a Comment