random numbers n.
Skip this Video
Loading SlideShow in 5 Seconds..
Random Numbers PowerPoint Presentation
Download Presentation
Random Numbers

play fullscreen
1 / 4
Download Presentation

Random Numbers - PowerPoint PPT Presentation

elaina
119 Views
Download Presentation

Random Numbers

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Random Numbers

  2. 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) - 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;