23.11.2014 Views

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

A common punishment for school children is to write out a sentence multiple<br />

times. Write a <strong>Java</strong> st<strong>and</strong>-alone program that will write out the follow<strong>in</strong>g<br />

sentence one hundred times: "I will never spam my friends aga<strong>in</strong>." Your<br />

program should number each of the sentences <strong>and</strong> it should make eight different<br />

r<strong>and</strong>om-look<strong>in</strong>g typos.<br />

P-1.2<br />

(For those who know <strong>Java</strong> graphical user <strong>in</strong>terface methods) Def<strong>in</strong>e a<br />

GraphicalTest class that tests the functionality of the CreditCard class from<br />

Code Fragment 1.5 us<strong>in</strong>g text fields <strong>and</strong> buttons.<br />

P-1.3<br />

The birthday paradox says that the probability that two people <strong>in</strong> a room will<br />

have the same birthday is more than half as long as n, the number of people <strong>in</strong><br />

the room, is more than 23. This property is not really a paradox, but many<br />

people f<strong>in</strong>d it surpris<strong>in</strong>g. Design a <strong>Java</strong> program that can test this paradox by a<br />

series of experiments on r<strong>and</strong>omly generated birthdays, which test this paradox<br />

for n = 5,10,15,20,…, 100.<br />

Chapter Notes<br />

For more detailed <strong>in</strong>formation about the <strong>Java</strong> programm<strong>in</strong>g language, we refer the<br />

reader to some of the f<strong>in</strong>e books about <strong>Java</strong>, <strong>in</strong>clud<strong>in</strong>g the books by Arnold <strong>and</strong><br />

Gosl<strong>in</strong>g [7], Cam-pione <strong>and</strong> Walrath [19], Cornell <strong>and</strong> Horstmann [26], Flanagan<br />

[34], <strong>and</strong> Horstmann [51], as well as Sun's <strong>Java</strong> Web site<br />

(http://www.java.sun.com).<br />

87

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!