A08f4 - CS1MD3 08F4 1 Assignment 4 Due Nov 25(Tuesday 23:59 In this assignment write all documents in javadoc style 1 Although it is often easier

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS1MD3 08F4. 1 Assignment 4 Due . Nov. 25 (Tuesday), 23:59. In this assignment, write all documents in javadoc style. 1. Although it is often easier to think of random numbers in the context of games of chance, they have other, more practical uses in computer science and mathematics. For example, you can use random numbers to generate a rough approximation of the constant π by writing a simple program that simulates a dart board. Imagine that you have a dart board hanging on your wall. It consists of a circle painted on a square backdrop. If you throw darts at this board in a random fashion, some will fall inside the circle. If the tosses are truly random, the ratio of the number of darts that land inside the circle to the total number of darts falling anywhere inside the square should be roughly equal to the ratio between the two areas. The ratio of the areas is independent of the actual size of the dart board, as illustrated by the following formula: darts falling inside the circle darts falling inside the square ≈ area of the circle area of the square = πr 2 4 r 2 = π 4 . To simulate this process in a program, imagine that the dart board is drawn in the standard Cartesian coordinate plane you learned about in high school. You can model the process of throwing a dart randomly at the square by generating two random floating-point numbers x and y , each of which lies between- 1 and 1. This ( x, y ) point always lies somewhere inside the square. The point ( x, y ) lies inside the circle if...
View Full Document

This note was uploaded on 10/27/2009 for the course COMP SCI 1MD3 taught by Professor Various during the Winter '07 term at McMaster University.

Page1 / 3

A08f4 - CS1MD3 08F4 1 Assignment 4 Due Nov 25(Tuesday 23:59 In this assignment write all documents in javadoc style 1 Although it is often easier

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online