Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Fill blanks of the following code segment that simulate rolling two six-sided dice and getting the sum using discrete() method of StdRandom class on page

Fill blanks of the following code segment that simulate rolling two six-sided dice and getting the sum using discrete() method of StdRandom class on page 226 of the textbook. [5 points]

This is a java program

int sum, eye1, eye2;

____________ p = _________________;

for (int i=0; i<6; i++) _____________________

eye1 = ________________________;

eye2 = ________________________;

sum = eye1 + eye2

this is StdRandom program from p.226

the question comes from Introduction to Programming in Java

This is the book website: http://introcs.cs.princeton.edu/java/home/

this is StdRandom program from p.226 public class StdRandom { public static int uniform(int N) {return (int)(Math.random()*N);} public static double uniform(double lo, double hi) {return lo +Math.random()*(hi-lo);} public static boolean bernoulli(double p) {return Math.random()= 1 || r == 0); return x * Math.sqrt(-2 * Math.log(r) / r); } public static double gaussian(double m, double s) {return m+s*gaussian();} public static int discrete(double[] a){ double r =uniform(0.0,1.0); double sum=0.0; for(int i=0; ir)return i; } return a.length-1; } public static void main(String[] args) { int N=Integer.parseInt(args[0]); double[]t={.5,.3,.1,.1}; for(int i=0; i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Joe Celkos Data And Databases Concepts In Practice

Authors: Joe Celko

1st Edition

1558604324, 978-1558604322

More Books

Students also viewed these Databases questions

Question

=+j Enabling a productive global workforce.

Answered: 1 week ago

Question

=+ Are you interested in creating or

Answered: 1 week ago

Question

=+working on a micro-multinational?

Answered: 1 week ago