
-----------------------------------
xmdxtreme
Sat May 15, 2004 9:46 pm

ok i have rand int problems here :D
-----------------------------------
See i want my program to creat random accounts till 4 digits excluding MG- at the begining like i want it to make account like:
MG-3445
MG-3425
can somoene help me i tried real hard i cant get it to work like this.
then just to let you know later on when the user type the account number it will look at the fisrt 3 characters MG- then it will know it has to go to manager account. but if it SC- at the begining then it will take them to Savings and chequings account. its sound a bit complicated :roll:  lol

-----------------------------------
xmdxtreme
Sat May 15, 2004 10:01 pm


-----------------------------------
please help  :oops: i got 1 more day for my first report.

-----------------------------------
jonos
Sat May 15, 2004 10:13 pm


-----------------------------------
Well you should just put the randomly generated accounts in an array and check the array against what they entered. Post some code so we know what you mean.

-----------------------------------
SuperGenius
Sat May 15, 2004 10:13 pm


-----------------------------------
ok. in a loop create a random integer and pass the value to a string which already includes the prefix you want. 
accountnum will of course be a string var, and prefix would also be one, with a value like "MG" You could also create the other types of accounts by changing the prefix that is used


accountnum (a) := prefix + "-" + intstr (randomnumber)

-----------------------------------
xmdxtreme
Sun May 16, 2004 7:04 am


-----------------------------------
I dont get it should i use a for loop or loop.
BTW can you explain your code sry.

-----------------------------------
we64
Sun May 16, 2004 8:03 am


-----------------------------------
I think this is what he meant:

var accountnum : array 1 .. 10 of string
var prefix : string := "MG"
var randomnumber : int
for a : 1 .. 10
    randint (randomnumber, 1000, 9999)
    accountnum (a) := prefix + "-" + intstr (randomnumber)
    put accountnum (a)
end for


-----------------------------------
xmdxtreme
Sun May 16, 2004 8:10 am


-----------------------------------
thank you! +10 bits

-----------------------------------
Martin
Sun May 16, 2004 1:06 pm


-----------------------------------
Just an FYI, Rand.Int(low, high) is easier to use, because it is a function instead of a procedure. This way, your code would look like this (much shorter)

var accountnum : array 1 .. 10 of string 
var prefix : string := "MG" 
for a : 1 .. 10 
    accountnum (a) := prefix + "-" + intstr (Rand.Int (1000,9999)) 
    put accountnum (a) 
end for

-----------------------------------
SuperGenius
Sun May 16, 2004 2:23 pm


-----------------------------------


var accountnum : array 1 .. 10 of string 
var prefix : string := "MG" 
for a : 1 .. 10 
    accountnum (a) := prefix + "-" + intstr (Rand.Int (1000,9999)) 
    put accountnum (a) 
end for

this is indeed what I meant, I was just hoping that you could come up with that yourself though.
