RandomData - break } case 'E':{ result =

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 //REMEMBER TO CHANGE THE FILE EXTENSION TO .JAVA FOR THIS TO WORK IN A COMPILER!!! public class RandomData { p public static int getInt(char type, int a, int b){ int result i switch(type){ case 'N':{ result = (int)Math.floor(a + b*Math.cos(2*Math.PI*Math.random()) * Math.sqrt(-2 * Math.log(Math.random()))) break } case 'n':{ result = (int)Math.floor(a + b*Math.cos(2*Math.PI*Math.random()) * Math.sqrt(-2 * Math.log(Math.random())))
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: break } case 'E':{ result = (int)Math.floor(-1*a*Math.log(Math.random())) break } case 'e':{ result = (int)Math.floor(-1*a*Math.log(Math.random())) break } default:{ result = result = (int)Math.floor(a + Math.random()*(b+1-a)) break } } return result } }...
View Full Document

Ask a homework question - tutors are online