Computer Science 202
Introduction to Programming

Fall 2012, The College of Saint Rose

Lecture 18: More Random Numbers; File I/O
Date: Tuesday, October 30, 2012

Agenda

Lecture Assignment 18

Due at the start of class, Thursday, November 1.

Please submit answers to these questions in Blackboard by the start of class. We will discuss these questions at the start of class, so no late submissions are accepted.

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. You may enter your responses directly in Blackboard or attach a document. This is worth 10 lecture assignment points.

Examples

Links