Random Number Question
-
I am working on a school project which calls for a random number based on user input and unfortunately I cannot seem to find how to do this. My book does not offer a very good explanation of this and when I search for this online I get some very confusing results. Here is the problem in a nutshell: I am creating a math game to be used by children. They need to provide which operator they want and choose the maximum numbers to use when generating the problems. My random generator needs to be based on what the maximum numbers are. For example: User input: maxNumber1: 5 maxNumber2: 10 random generated problem: 5+10 (or any other problem using 1-5 and 1-10) I am not asking for anyone to solve my problem for me but I would appreciate a little direction as to where I can find the answer that would pertain to this scenario. Thanks in advance!
-
I am working on a school project which calls for a random number based on user input and unfortunately I cannot seem to find how to do this. My book does not offer a very good explanation of this and when I search for this online I get some very confusing results. Here is the problem in a nutshell: I am creating a math game to be used by children. They need to provide which operator they want and choose the maximum numbers to use when generating the problems. My random generator needs to be based on what the maximum numbers are. For example: User input: maxNumber1: 5 maxNumber2: 10 random generated problem: 5+10 (or any other problem using 1-5 and 1-10) I am not asking for anyone to solve my problem for me but I would appreciate a little direction as to where I can find the answer that would pertain to this scenario. Thanks in advance!
Without negative values? I guess you should look at
Random.Next(int)
[^] Don't forget to only create 1 instance of Random, don't make a new one every time (ok I know it's not like it will really matter in this case, but it's still bad practice to do it) -
I am working on a school project which calls for a random number based on user input and unfortunately I cannot seem to find how to do this. My book does not offer a very good explanation of this and when I search for this online I get some very confusing results. Here is the problem in a nutshell: I am creating a math game to be used by children. They need to provide which operator they want and choose the maximum numbers to use when generating the problems. My random generator needs to be based on what the maximum numbers are. For example: User input: maxNumber1: 5 maxNumber2: 10 random generated problem: 5+10 (or any other problem using 1-5 and 1-10) I am not asking for anyone to solve my problem for me but I would appreciate a little direction as to where I can find the answer that would pertain to this scenario. Thanks in advance!
For instance: Random RandomClass = new Random(); // The Next method should be called with two arguments: the minimum value and the maximum value. int RandomNumber = RandomClass.Next(maxNumber+1, maxNumber+2);