Download presentation
Presentation is loading. Please wait.
Published byImogene Tucker Modified over 9 years ago
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;
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.