milad yalda wrote:
the numbers randomly selected how can I put them in a array?
Ralph Cook wrote:They are in an array. What is your question again?
milad yalda wrote:
Ralph Cook wrote:They are in an array. What is your question again?
I have random numbers and then put them in another array and sort the numbers in excess of 499 put them in a array and those less than 499 in a different vector and print out.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
milad yalda wrote:When you enter 4, the program will print 4 random numbers so my problem is how can I add the 4 random numbers in an new array? I do not want the whole solution
Joanne
Joanne Neal wrote:
milad yalda wrote:When you enter 4, the program will print 4 random numbers so my problem is how can I add the 4 random numbers in an new array? I do not want the whole solution
I'm still confused. You know how to create an array - you do it on line 9. You know how to add a number to an array - you do it on line 15. So what exactly are you having a problem with ?
milad yalda wrote:now I've solved half, the problem is that I get lot of zeroes when I run why?
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
milad yalda wrote:now I've solved half, the problem is that I get lot of zeroes when I run why?
Because you haven't taken the advice in my first post (see above).
BTW, strictly speaking, what you're doing is not a sort; it's a filter.
Winston
milad yalda wrote:hi wiston, when i put "int[] nummber =new int[tal];" så i get this message "Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3
at Vek.main(Vek.java:18)"
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
milad yalda wrote:hi wiston, when i put "int[] nummber =new int[tal];" så i get this message "Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3
at Vek.main(Vek.java:18)"
Because your for loop is still wrong.
If 'tal' is 3 and you create an array of 3 numbers with
double[] v = new double[tal];
what is the largest valid index for 'v'?
Winston
milad yalda wrote:
Winston Gutkowski wrote:
milad yalda wrote:hi wiston, when i put "int[] nummber =new int[tal];" så i get this message "Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3
at Vek.main(Vek.java:18)"
Because your for loop is still wrong.
If 'tal' is 3 and you create an array of 3 numbers with
double[] v = new double[tal];
what is the largest valid index for 'v'?
Winston
for(int i=0; i<=v.length; i++) so i have change the loop but i still get the message !!!