#using array to store random num generated

15 messages · Page 1 of 1 (latest)

opal sandal
#

im trying to generate a random 6 digit number and store it in array but its not working

amber cedarBOT
#

This post has been reserved for your question.

Hey @opal sandal! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

prisma zephyr
#

cannot convert from int to int[]
int[] is a array. u have to index it to access the elements in java
int[0] = wompwomp

opal sandal
#

int [] sixDig = new int [1];
sixDig[0] = (int) (Math.random()*1000000);

#

i used this and it works

#

but does that mean this is stored or is it gonna keep generating a new different number

#

because i want to store the generated number for later when the user is asked to enter the acc number

vivid monolith
#

This isn't math, this is computing. You're not providing a formula you're providing instructions. It is stored

#

Unless you mean from one run of the program to another

opal sandal
#

Oh okay

#

theres something else im facing a problem with

#

i did an if statement but it keeps showing the opposite results

#

when pass equals pass2 it should print password created succcessfully but instead it shows try again