Presentation is loading. Please wait.

Presentation is loading. Please wait.

Random Numbers. Are a series of numbers that have no pattern to them Ex) 7, 31, 4, 9, 8, 99… Random Numbers are used in… - Computer Games - Lotteries(6-49)

Similar presentations


Presentation on theme: "Random Numbers. Are a series of numbers that have no pattern to them Ex) 7, 31, 4, 9, 8, 99… Random Numbers are used in… - Computer Games - Lotteries(6-49)"— Presentation transcript:

1 Random Numbers

2 Are a series of numbers that have no pattern to them Ex) 7, 31, 4, 9, 8, 99… Random Numbers are used in… - Computer Games - Lotteries(6-49) - Screen Savers

3 Math.random  Part of the java.lang package  The random() methods generates a double between 0 and 1.0. For example, double rNum; rNum = Math.random();  A random integer in a range is generated by using the expression: (highNum – lowNum + 1) * Math.random() + lowNum

4 Examples To generate Random Numbers between 20 and 100 rNum= (100 – 20+1) * Math.random() + 20; To generate Random Numbers between 10 and 50 rNum= (50 – 10+1) * Math.random() + 10;


Download ppt "Random Numbers. Are a series of numbers that have no pattern to them Ex) 7, 31, 4, 9, 8, 99… Random Numbers are used in… - Computer Games - Lotteries(6-49)"

Similar presentations


Ads by Google