----------------------------------- JR Tue Feb 03, 2004 5:15 pm Help with random number program ----------------------------------- hey, i'm new to the site. i got a problem with a program, i need to to make 10 random numbers but with one program. thats what i got for now. var x,n1,n2,count:int put " choose your low number " get n1 put " choose your hight number " get n2 randint (x,n1,n2) count:=1 put " you got ", x loop randint (x,n1,n2) if count:=10 then exit end if end loop any tips? ----------------------------------- santabruzer Tue Feb 03, 2004 5:22 pm ----------------------------------- here's your prog.. just a abit changed.. i say for statement is better.. but just continuing what you did: var x, n1, n2, count : int put " choose your low number " get n1 put " choose your hight number " get n2 count := 1 loop randint (x, n1, n2) put " you got ", x randint (x, n1, n2) count += 1 if count = 10 then exit end if end loop ----------------------------------- JR Tue Feb 03, 2004 5:28 pm ----------------------------------- k thx alot ----------------------------------- Cervantes Tue Feb 03, 2004 5:35 pm ----------------------------------- for clarification and cleaning things up. count += 1 is the same as count := count + 1 also you don't need to have randint twice inside the loop, get rid of the lower one. also, though this works if count = 10 then exit end if it saves you code to just put exit when count = 10 ----------------------------------- JR Tue Feb 03, 2004 5:51 pm ----------------------------------- bah im such a noob in turing. i got another question. i made this program var x,y,count:int randint (x,1,6) randint (y,1,6) put " your dice roll is ", x+y count := 1 loop randint (x, 1, 6) randint (y, 1, 6) put " you got ", x+y randint (x, 1, 6) count += 1 if count = 100 then exit end if end loop now i figured out how to do 100 dice rolls, my problem is how do i set how many vars of each number where used? like if there was 20 1's 20 2's ect how do i find how many 1-6 there was? ----------------------------------- Cervantes Tue Feb 03, 2004 6:09 pm ----------------------------------- you could use an array to make 100 vars, but you don't need to do that use a for statement.. santa mentioned them earlier. var howmany : int put "How many times would you like to roll the dice? : " .. get howmany var roll : int var one, two, three, four, five, six : int := 0 for i : 1 .. howmany randint (roll, 1, 6) if roll = 1 then one += 1 end if if roll = 2 then two += 1 end if if roll = 3 then three += 1 end if if roll = 4 then four += 1 end if if roll = 5 then five += 1 end if if roll = 6 then six += 1 end if put "Roll : ", roll end for cls put "One's : ", one put "Twos's : ", two put "Three's : ", three put "Four's : ", four put "Five's : ", five put "Six's : ", six that's only for rolling 1 die though.. you can alter that prog so that you can roll 2 dies and add them together and determine how many of what you get. ----------------------------------- Andy Tue Feb 03, 2004 8:32 pm ----------------------------------- y dont u have arrays? just go dice(Rand.Int(1,6))+=1 ----------------------------------- santabruzer Tue Feb 03, 2004 8:40 pm ----------------------------------- *whistles*... var dice : array 1 .. 6 of int := init (0, 0, 0, 0, 0, 0) for i : 1 .. 100 dice (Rand.Int (1, 6)) += 1 end for cls put "One's : ", dice (1) put "Twos's : ", dice (2) put "Three's : ", dice (3) put "Four's : ", dice (4) put "Five's : ", dice (5) put "Six's : ", dice (6) ----------------------------------- Thuged_Out_G Wed Feb 04, 2004 8:41 pm ----------------------------------- dammit, i never even thought of that...i did the same program...but i used 6 different for loops i think...ill post the method i did later on so you can all laugh at it :lol: