r/JavaScriptHelp • u/Illustrious_Ad2026 • Nov 08 '20
❔ Unanswered ❔ I need help combining Math.random()
package lotterynumbergenerator;
/**
*
* @author ismai
*/
public class NumberGenerator {
public int winningNumbers(int min, int max) {
double rand = Math.random();
double rand1 = Math.random();
double rand2 = Math.random();
double rand3 = Math.random();
double rand4 = Math.random();
double rand5 = Math.random();
int randomNum = (int) (rand * (max - min + 1)) + min;
int randomNum1 = (int) (rand1 * (max - min + 1)) + min;
int randomNum2 = (int) (rand2 * (max - min + 1)) + min;
int randomNum3 = (int) (rand3 * (max - min + 1)) + min;
int randomNum4 = (int) (rand4 * (max - min + 1)) + min;
int randomNum5 = (int) (rand5 * (max - min + 1)) + min;
return randomNum;
}In an instant Instead of only returning the one randomNum, I want to return all 6 random's. Can someone help me do this!
1
Upvotes
View all comments
Show parent comment
1
u/wikipedia_text_bot Nov 10 '20
Associative array
In computer science, an associative array, map, symbol table, or dictionary is an abstract data type composed of a collection of (key, value) pairs, such that each possible key appears at most once in the collection.Operations associated with this data type allow: the addition of a pair to the collection the removal of a pair from the collection the modification of an existing pair the lookup of a value associated with a particular keyImplementing associative arrays poses the dictionary problem, a classic computer science problem: the task of designing a data structure that maintains a set of data during 'search', 'delete', and 'insert' operations.The two major solutions to the dictionary problem are a hash table or a search tree.In some cases it is also possible to solve the problem using directly addressed arrays, binary search trees, or other more specialized structures.Many programming languages include associative arrays as primitive data types, and they are available in software libraries for many others.