ptg7068951
216 HOUR 15:Responding to User Input
After you add the shaded lines, you can run the application, which is capa-
ble of testing your lotto skills for thousands of years. As you might expect,
these lotteries are an exercise in futility. The chance of winning a 6-out-of-6
lotto drawing in a lifetime is extremely slim, even if you live as long as a
biblical figure.
Summary
You can create a professional-looking program with a modest amount of
programming by using Swing. Although the LottoMadnessapplication is
longer than many of the examples you have worked in during the last 14
hours, half of the program was comprised of statements to build the inter-
face.
If you spend some time running the application, you become even more
bitter and envious about the good fortune of the people who win these six-
number lottery drawings.
My most recent run of the program indicates that I could blow $27,000 and
the best 266 years of my life buying tickets, only to win a handful of 4-out-
of-6 and 3-out-of-6 prizes. In comparison to those odds, the chance to make
your Java programming skills pay off is practically a sure thing.
NOTE
The book’s website at
http://www.java24hours.com contains
a link to an applet version of
theLottoMadnessprogram. At
the time of this printing,
410,732,244 drawings have
been conducted,which equals
3.9 million years of twice-
weekly drawings. There have
been 6,364,880 3-out-of-6 win-
ners,337,285 4-out-of-6 win-
ners,6,476 5-out-of-6 winners,
and 51 6-out-of-6 winners
(roughly one out of every 8 mil-
lion drawings). The first person
to win this fictional lottery was
Bill Teer on August. 14,2000,
more than four years after the
applet went online. His num-
bers were 3,7, 1, 15,34,and
43,and it only took him
241,225 drawings (2,319.47
years) to win.