Java Reference
In-Depth Information
2. Enter lines 39 through 44 as shown from Figure 4-13.
TextPad displays the finish() method in the coding window. The closing
brace for the class moves down to line 45. When called, the finish() method
will exit the program (Figure 4-15).
finish()
method
FIGURE 4-15
3. With the Data Disk in drive A, compile the program by clicking Compile
Java on the Tools menu. If TextPad notifies you of errors, click
Commission.java in the Selector window, fix the errors, and then
compile again. When the program compiles with no errors, click Run
Java Application on the Tools menu.
TextPad compiles and runs the program. The program displays the Input
dialog box (Figure 4-16).
Input
dialog box
Cancel
button
FIGURE 4-16
4. Click the Cancel button. Click the Close button in the command prompt
window title bar.
The Commission program terminates and the command prompt window
closes.
If the user clicks the Cancel button during program execution, the program
does not need to try to convert the input value to a double data type. The if
statement thus is placed before the parseDouble() method to make the program
code more efficient.
 
Search WWH ::




Custom Search