Java Reference
In-Depth Information
Programming Assignments
1 Understanding Import Statements
The BillPayer program created in this chapter used six import statements. Make
a list of the import statements and, under each one, list all of the classes and
methods used in the program that come from that imported package. If neces-
sary, use the Java API to help you discover which methods belong to which
classes. Another way you can discover to which package a class or method
belongs is to insert a comment mark (//) before the import statements, one at a
time, and try to compile the program. TextPad will tell you it cannot resolve the
symbol for the class that has no associated import statement.
2 Creating JOptionPane boxes
Figure 8-36 displays a program that accepts data for city sticker applications
in the town of Flora. The Flora program is located in the Chapter08 folder of
the Data Disk that accompanies this topic. A Java source code file named
MessageBox also is on the Data Disk. The Flora program needs to generate sev-
eral message boxes for the user, but calls a programmer-supplied MessageBox
class rather than using JOptionPane. You have been asked to update the Flora
program to use appropriate JOptionPane boxes.
FIGURE 8-36
Perform the following steps.
1. Start TextPad and open the file named MessageBox. Print a copy for your
reference.
2. Compile the MessageBox file.
3. Open the file named Flora. Print a copy for your reference.
4. Compile and run the Flora program.
5. Try entering data appropriately, then try omitting data fields. Notice when
the message boxes are displayed. Close the program.
Search WWH ::




Custom Search