i need help comparing 10 numbers

hi i need help comparing ten numbers given by the user and stored in the form of an array. the numbers cannot be repeated. thanks
[136 byte] By [colombia123a] at [2007-11-27 6:53:44]
# 1
Could be be a little more specific? What exactly do you mean by comparing? And what is the program supposed to do?Please ask a specific question next time as opposed to just saying "I need help."
C_Zhaoa at 2007-7-12 18:28:32 > top of Java-index,Other Topics,Algorithms...
# 2

> hi i need help comparing ten numbers given by the

> user and stored in the form of an array. the numbers

> cannot be repeated. thanks

Get user input:

http://java.sun.com/j2se/1.5.0/docs/api/java/util/Scanner.html

Storing unique objects:

http://java.sun.com/j2se/1.5.0/docs/api/java/util/Set.html

After your set is of size 10, you can convert it to an array.

prometheuzza at 2007-7-12 18:28:32 > top of Java-index,Other Topics,Algorithms...
# 3

what i need to do is get the user to enter ten numbers without repeating any of the numbers. I can get the user to input the ten numbers using a 'for' loop and storing the numbers in arrays. What i cannot do is compare them so if any of them are the same the program sends an error message and asks the user to input the ten numbers again until non of the numbers given by the user are the same

colombia123a at 2007-7-12 18:28:32 > top of Java-index,Other Topics,Algorithms...
# 4
prometheuzza at 2007-7-12 18:28:32 > top of Java-index,Other Topics,Algorithms...
# 5

Suppose you have already entered 3 numbers

Now you are entering a fourth. Can you think of any way to check if the 4th number matches any of the first three? Perhaps you could compare each of the three previous numbers one after the other with the fourth. If none of them match, well then the fourth number is ok and now you have a list of 4 numbers that are all different.

Does that give you any ideas?

marlin314a at 2007-7-12 18:28:32 > top of Java-index,Other Topics,Algorithms...
# 6

> what i need to do is get the user to enter ten

> numbers without repeating any of the numbers. I can

> get the user to input the ten numbers using a 'for'

> loop and storing the numbers in arrays. What i cannot

> do is compare them so if any of them are the same the

> program sends an error message and asks the user to

> input the ten numbers again until non of the numbers

> given by the user are the same

It sounds like a job for Set. Check it out!

http://java.sun.com/j2se/1.4.2/docs/api/java/util/Set.html#add(java.lang.Object)

manuel.leiriaa at 2007-7-12 18:28:32 > top of Java-index,Other Topics,Algorithms...