UseRandom - System.out.println((int) (6 * Math.random()));

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

View Full Document Right Arrow Icon
// File: UseRandom.java // Course: CSC 211 // Author: Amber Settle // Purpose: Illustrate the use of Math.random / public class UseRandom { public static void main(String[] args) { System.out.println("Five pseudorandom doubles in the range [0,1):"); System.out.println(Math.random()); System.out.println(Math.random()); System.out.println(Math.random()); System.out.println(Math.random()); System.out.println(Math.random()); System.out.println(); S System.out.println("Five pseudorandom doubles in the range [0,6):"); System.out.println(6 * Math.random()); System.out.println(6 * Math.random()); System.out.println(6 * Math.random()); System.out.println(6 * Math.random()); System.out.println(6 * Math.random()); System.out.println(); S System.out.println("Five pseudorandom integers in the range [0,5]:");
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: System.out.println((int) (6 * Math.random())); System.out.println((int) (6 * Math.random())); System.out.println((int) (6 * Math.random())); System.out.println((int) (6 * Math.random())); System.out.println((int) (6 * Math.random())); System.out.println(); S System.out.println("Five pseudorandom integers in the range [1,6]:"); System.out.println(1 + ((int) (6 * Math.random()))); System.out.println(1 + ((int) (6 * Math.random()))); System.out.println(1 + ((int) (6 * Math.random()))); System.out.println(1 + ((int) (6 * Math.random()))); System.out.println(1 + ((int) (6 * Math.random()))); System.out.println(); S } }...
View Full Document

This note was uploaded on 03/05/2011 for the course CSCI 384 taught by Professor Drchan during the Spring '11 term at CA Health Sciences.

Ask a homework question - tutors are online