Computer Science 202
Introduction to Programming

Fall 2013, The College of Saint Rose

Lecture 21: More on Random
Date: Thursday, November 21, 2013


Agenda

Lecture 21 Assignment

Due at the start of class, Tuesday, November 26.

Please submit answers to these questions in Submission Box under "LA21" by the start of our next class. We will discuss these questions at the start of class, so no late submissions are accepted. Please be sure that your name is clearly indicated in all submissions.

(6 points) Assume you have a Java program that includes the following construction of a random number generator object:

  Random r = new Random();

Complete the following Java statements so that they accomplish the task as described in the preceding comment.

// x should contain an integer between 0 and 999 (1 point)
int x = 

// y should contain an integer between 1 and 50 (2 points)
int y = 

// z should contain an integer between -10 and 10 (2 points)
int z =

// a should contain a floating-point value between 0.0 and 2.0 (1 point)
double a = 

// b should contain a floating-point value between 1.0 and 2.0 (2 points)
double b =

// c should contain a floating-point value between 10.0 and 50.0 (2 points)
double c =

You do not need to type these in and run them unless you wish to do so. (But you should still at least write down your answers and turn them in, of course.)

Examples