LoginLogin

How do I declare random numbers?

Root / Programming Questions / [.]

Jerm504Created:
I am working on a program, and I need to know of there is a way to declare a variable that is equal to a random number between 2 set numbers. If it is possible this would help me to.finish the entire project. The basis of what I want to do is built around being able to determine that those random numbers are true.

I am working on a program, and I need to know of there is a way to declare a variable that is equal to a random number between 2 set numbers. If it is possible this would help me to.finish the entire project. The basis of what I want to do is built around being able to determine that those random numbers are true.
What do you mean by "random numbers are true?" If you want "random" numbers you can get a number using RND(maxnum) and it will return a number between 0 and maxnum-1. There are a few different ways you could use this, like if you needed a choice between say 5 and 3 you could create an array with 5 and 3 in it and use RND as the index, or you could use some Boolean stuff like num=3+RND(2)*2 Odds are you can use RND. EDIT: If you need it between two numbers, use this: num=min+RND(max-min), I think that might work.

I am working on a program, and I need to know of there is a way to declare a variable that is equal to a random number between 2 set numbers. If it is possible this would help me to.finish the entire project. The basis of what I want to do is built around being able to determine that those random numbers are true.
What do you mean by "random numbers are true?" If you want "random" numbers you can get a number using RND(maxnum) and it will return a number between 0 and maxnum-1. There are a few different ways you could use this, like if you needed a choice between say 5 and 3 you could create an array with 5 and 3 in it and use RND as the index, or you could use some Boolean stuff like num=3+RND(2)*2 Odds are you can use RND. EDIT: If you need it between two numbers, use this: num=min+RND(max-min), I think that might work.
I want the program to determine someone zodiac. So I used the input command to have the user input their birthday with the format m,d,y. So when they input they input the month and day I want it to determine what zodiac they are based on the month and the day. For example Pisces is fed 19 through March 20. So for Feb I would put If m==2 then d== a random number between 19 and 28 (the days left in the month that can be selected) If d== a random number between 19 and 28 then print "you are Pisces" Of course it's gonna get more complex but I first need the program to determine what number to check are corrects. I would have to do this for each month and it's days corresponding to the zodiac. Also I am new to this forum deal and I don't really know how to use it to we'll I apologize. I also just started programing a week ago so yeh.

Ah, you don't want to check a random number, you want to check if it is any of those numbers. i.e. checking if numbers are greater than or less than other certain numbers. If (m==2 and d>=19) or (m==3 and d<= 20) then print "you are Pisces"

Ah, you don't want to check a random number, you want to check if it is any of those numbers. i.e. checking if numbers are greater than or less than other certain numbers. If (m==2 and d>=19) or (m==3 and d<= 20) then print "you are Pisces"
Ahh so simple. I will try that and see if it works that also makes the code much shorter. I have it set up to check for zodiac from @zodiac I set up a gosub for @Pisces which is where I will put the code for Pisces and so on. Thank you kind sir . I have been stumped since last night after I finished the title screen.